<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extracting data in between strings...using perl in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086532#M93200</link>
    <description>Wait for Hein or Merijn to post their fabulous perl answers    :)</description>
    <pubDate>Thu, 03 Jan 2008 19:53:20 GMT</pubDate>
    <dc:creator>Geoff Wild</dc:creator>
    <dc:date>2008-01-03T19:53:20Z</dc:date>
    <item>
      <title>Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086527#M93195</link>
      <description>&lt;!--!*#--&gt;I have a variable called WebJump in a perl script.&lt;BR /&gt;&lt;BR /&gt;When i print the content it gives me this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TITLE&gt;&lt;/TITLE&gt;T&lt;BR /&gt;his page is used to hold your data while you are being authorized for your reque&lt;BR /&gt;st.&lt;BR /&gt;&lt;BR /&gt;You will be forwarded to continue the authorization process. If this &lt;BR /&gt;does not happen automatically, please click the Continue button below.&lt;FORM name=""&gt;="AUTOSUBMIT" METHOD="POST" STARThttps://test.ip.com/siteminderagent/forms/&lt;BR /&gt;login.fcc?TYPE=33554433&amp;amp;REALMOID=06-00034bb7-e037-116f-8241-808d67a50008&amp;amp;GUID=&amp;amp;S&lt;BR /&gt;MAUTHREASON=0&amp;amp;METHOD=POST&amp;amp;SMAGENTNAME=$SM$8OJVwItP%2fV8GXRhL%2fhch6KJt3EvC2AWLQ7&lt;BR /&gt;%2bWLfTgx3%2bWD7k%2buJc3dVSFPOr1jTxg&amp;amp;TARGET=$SM$%2fEND="HIDDEN" NAME="SMPostPres&lt;BR /&gt;erve" VALUE="S1NJbjNmby81VzRqMmo0cTNuWm9NdFo3cVpZSlF6enpMc2laNWZrcnRudlhWVEUzM0x&lt;BR /&gt;UTHVPR1Y3REpwNnUwM1ZVd1IySFdQZkRDRmpUQldrV01ybk9pcEFBZnpzNmg4RG1yQ0lRQUNzbTFMekd&lt;BR /&gt;iUG9Eck02M2NUcis4RG5YQ3l2dkZHOGp4WDRPbHJJTFdJOXUvbnFBPT0END="SUBMIT" VALUE="Cont&lt;BR /&gt;inue"&amp;gt;&lt;/FORM&gt;&lt;BR /&gt;&lt;BR /&gt;I want to print everthing between START and END and then reassign it to my WebJump variable.&lt;BR /&gt;&lt;BR /&gt;Any ideas?</description>
      <pubDate>Thu, 03 Jan 2008 19:20:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086527#M93195</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2008-01-03T19:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086528#M93196</link>
      <description>This one is actually an example in the book.&lt;BR /&gt;&lt;BR /&gt;Use sed.&lt;BR /&gt;&lt;BR /&gt;WebJump=`echo "the_stuff"|sed /^BEGIN/,/^END/p`&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jan 2008 19:41:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086528#M93196</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-01-03T19:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086529#M93197</link>
      <description>How can i do it in PERL?</description>
      <pubDate>Thu, 03 Jan 2008 19:44:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086529#M93197</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2008-01-03T19:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086530#M93198</link>
      <description>Alright, almost easy, cept the START is really STARThttp.... and also the END...&lt;BR /&gt;&lt;BR /&gt;Will let you know if I find something.  SOrry for the quick wrong answer.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jan 2008 19:45:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086530#M93198</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-01-03T19:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086531#M93199</link>
      <description>I can change the START END to anything in need to.&lt;BR /&gt;&lt;BR /&gt;IE &lt;START&gt;  &lt;END&gt;&lt;BR /&gt;&lt;BR /&gt; ...whatever.....&lt;BR /&gt;&lt;BR /&gt;I simply used search and replace....&lt;/END&gt;&lt;/START&gt;</description>
      <pubDate>Thu, 03 Jan 2008 19:47:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086531#M93199</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2008-01-03T19:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086532#M93200</link>
      <description>Wait for Hein or Merijn to post their fabulous perl answers    :)</description>
      <pubDate>Thu, 03 Jan 2008 19:53:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086532#M93200</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2008-01-03T19:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086533#M93201</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;If whole text is single line (otherwise please parse into single line) &lt;BR /&gt;&lt;BR /&gt;use index function to find START&lt;BR /&gt;use substr function to extract from START to end of the line (str1)&lt;BR /&gt;&lt;BR /&gt;Then you have 2 END in text, &lt;BR /&gt;so if you want to extract START and first END &lt;BR /&gt;again use index function with str1 to find first END's position. and use substr&lt;BR /&gt;&lt;BR /&gt;if you want to extract BEGIN and second END&lt;BR /&gt;use rindex with str1 to find position of second END, then subtract it from len($str1)&lt;BR /&gt;use again substr &lt;BR /&gt;&lt;BR /&gt;I have no perl interpreter on this computer so I hope this algorithm will help to you &lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Murat</description>
      <pubDate>Thu, 03 Jan 2008 19:54:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086533#M93201</guid>
      <dc:creator>Murat SULUHAN</dc:creator>
      <dc:date>2008-01-03T19:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086534#M93202</link>
      <description>Hi Jody: &lt;BR /&gt;&lt;BR /&gt;I assume from the content that you truly want everything between the strings START and END, disregarding any newline boundries. &lt;BR /&gt;&lt;BR /&gt;Using a copy-and-paste of your data : &lt;BR /&gt;&lt;BR /&gt;# echo ${WebJump}|perl -000 -nle 'print $1 if m/.*START(.*)END.*/s' &lt;BR /&gt;&lt;BR /&gt;Regards! &lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 03 Jan 2008 21:50:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086534#M93202</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-01-03T21:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086535#M93203</link>
      <description>Hi (again) Jody:&lt;BR /&gt;&lt;BR /&gt;Actually, here is a better representation of what you probably want.  It destructively updates the $WebJump scalar variable:&lt;BR /&gt;&lt;BR /&gt;# cat .jody.pl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $WebJump=q[&lt;TITLE&gt;&lt;/TITLE&gt;This page is used to hold your da&lt;BR /&gt;ta while you are being authorized for your reque st.&lt;BR /&gt;&lt;BR /&gt;You will be forwarded to continue the authorization process. If th&lt;BR /&gt;is does not happen automatically, please click the Continue button below.&lt;FORM name="AUTOSUBMIT" method="POST"&gt;est.ip.com/siteminderagent/forms/login.fcc?TYPE=33554433&amp;amp;REALMOID=06-00034bb7-e037-116f-8241-808d67a50008&amp;amp;GUID=&amp;amp;S MAUTHREASON=&lt;BR /&gt;0&amp;amp;METHOD=POST&amp;amp;SMAGENTNAME=$SM$8OJVwItP%2fV8GXRhL%2fhch6KJt3EvC2AWLQ7 %2bWLfTgx3%2bWD7k%2buJc3dVSFPOr1jTxg&amp;amp;TARGET=$SM$%2fEND="H&lt;BR /&gt;IDDEN"NAME="SMPostPreserve"VALUE="S1NJbjNmby81VzRqMmo0cTNuWm9NdFo3cVpZSlF6enpMc2laNWZrcnRudlhWVEUzM0x UTHVPR1Y3REpwNnUwM1ZVd1I&lt;BR /&gt;ySFdQZkRDRmpUQldrV01ybk9pcEFBZnpzNmg4RG1yQ0lRQUNzbTFMekdiUG9Eck02M2NUcis4RG5YQ3l2dkZHOGp4WDRPbHJJTFdJOXUvbnFBPT0END="SUBMIT"VA&lt;BR /&gt;LUE="Continue"&amp;gt;&lt;/FORM&gt;];&lt;BR /&gt;&lt;BR /&gt;( $WebJump ) = ( $WebJump =~ /START(.*)END/s );&lt;BR /&gt;print "$WebJump\n";&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jan 2008 22:30:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086535#M93203</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-01-03T22:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086536#M93204</link>
      <description>[Thanks Geoff! I haven't had much time to troll this forum.]&lt;BR /&gt;&lt;BR /&gt;Jody,&lt;BR /&gt;&lt;BR /&gt;Murat pointed out that there are two ENDs in the example. I believe you indicate that was just a bad example, thus nothing to worry about. (allthough it worries me when folks post bad examples, but that's my problem).&lt;BR /&gt;&lt;BR /&gt;Still, if you did have to deal with nested START/ENDs then you may want to be sure to know about the 'greedyness' of the * in perl.&lt;BR /&gt;&lt;BR /&gt;For example if the data was:&lt;BR /&gt;&lt;BR /&gt;x START y START a b d END z END&lt;BR /&gt;&lt;BR /&gt;JRF writes...&lt;BR /&gt;( $WebJump ) = ( $WebJump =~ /START(.*)END/s ); &lt;BR /&gt;&lt;BR /&gt;This is fine. But note that the .* in there is greedy and in my example will return " y START a b d END z "&lt;BR /&gt;&lt;BR /&gt;If you wanted the inner START/END, then use: .*?&lt;BR /&gt;&lt;BR /&gt;It will return " a b d "&lt;BR /&gt;&lt;BR /&gt;Cheers!&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jan 2008 01:06:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086536#M93204</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-01-04T01:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086537#M93205</link>
      <description>&lt;!--!*#--&gt;What Hein said, but then parsing HTML with regexes is still NOT safe.&lt;BR /&gt;&lt;BR /&gt;Have a look at the HTML::TreeBuilder module.&lt;BR /&gt;&lt;BR /&gt;--8&amp;lt;--- test.pl&lt;BR /&gt;#!/pro/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;use HTML::TreeBuilder;&lt;BR /&gt;&lt;BR /&gt;my $tree = HTML::TreeBuilder-&amp;gt;new;&lt;BR /&gt;&lt;BR /&gt;my $content = &amp;lt;&amp;lt;'EOH';&lt;BR /&gt;&lt;TITLE&gt;&lt;/TITLE&gt;&lt;BR /&gt;This page is used to hold your data while you are being authorized for your&lt;BR /&gt;request.&lt;BR /&gt;&lt;BR /&gt;You will be forwarded to continue the authorization process. If&lt;BR /&gt;this does not happen automatically, please click the Continue button below.&lt;BR /&gt;&lt;FORM name="AUTOSUBMIT" method="POST"&gt;STARThttps://test.ip.com/siteminderagent/forms/login.fcc?TYPE=33554433&amp;amp;REALMOID=06-00034bb7-e037-116f-8241-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=POST&amp;amp;SMAGENTNAME=$SM$8OJVwItP%2fV8GXRhL%2fhch6KJt3EvC2AWLQ7%2bWLfTgx3%2bWD7k%2buJc3dVSFPOr1jTxg&amp;amp;TARGET=$SM$%2fEND="HIDDEN"&lt;BR /&gt;NAME="SMPostPreserve"&lt;BR /&gt;VALUE="S1NJbjNmby81VzRqMmo0cTNuWm9NdFo3cVpZSlF6enpMc2laNWZrcnRudlhWVEUzM0xUTHVPR1Y3REpwNnUwM1ZVd1IySFdQZkRDRmpUQldrV01ybk9pcEFBZnpzNmg4RG1yQ0lRQUNzbTFMekdiUG9Eck02M2NUcis4RG5YQ3l2dkZHOGp4WDRPbHJJTFdJOXUvbnFBPT0END="SUBMIT"&lt;BR /&gt;VALUE="Continue"&amp;gt;&lt;/FORM&gt;&lt;BR /&gt;EOH&lt;BR /&gt;&lt;BR /&gt;$tree-&amp;gt;parse_content ($content);&lt;BR /&gt;# print $tree-&amp;gt;as_HTML (undef, "  ", {});&lt;BR /&gt;&lt;BR /&gt;foreach my $f ($tree-&amp;gt;look_down (_tag =&amp;gt; "form")) {&lt;BR /&gt;    # print "FORM:\n", $f-&amp;gt;as_HTML (undef, "  ", {});&lt;BR /&gt;    $f-&amp;gt;as_HTML (undef, "  ", {}) =~ m{\bstart(.*?)end}i and&lt;BR /&gt; print "START in FORM: $1\n";&lt;BR /&gt;    }&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;# perl test.pl&lt;BR /&gt;START in FORM: &lt;A href="https://test.ip.com/siteminderagent/forms/login.fcc?type=" target="_blank"&gt;https://test.ip.com/siteminderagent/forms/login.fcc?type=&lt;/A&gt;"33554433&amp;amp;REALMOID=06-00034bb7-e037-116f-8241-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=POST&amp;amp;SMAGENTNAME=$SM$8OJVwItP%2fV8GXRhL%2fhch6KJt3EvC2AWLQ7%2bWLfTgx3%2bWD7k%2buJc3dVSFPOr1jTxg&amp;amp;TARGET=$SM$%2f&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ who does not think this is clean HTML ]</description>
      <pubDate>Fri, 04 Jan 2008 08:14:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086537#M93205</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2008-01-04T08:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data in between strings...using perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086538#M93206</link>
      <description>&lt;!--!*#--&gt;I wound up using regular expressions butam looking forwardto messing withthe treebuilder but it is very very difficult.</description>
      <pubDate>Fri, 25 Jan 2008 02:39:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extracting-data-in-between-strings-using-perl/m-p/5086538#M93206</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2008-01-25T02:39:50Z</dc:date>
    </item>
  </channel>
</rss>

