On Feb 19, 2006, at 23:32, Bowen, Bruce wrote:

I have a text file with lines of varying length.

000,;,001,WL0,001,001,000,000,000,000
011,@D , 011,000,001,050,050,105,105,004,004,064,255,000,001,116,255,255,255,10 6,255,255,255,255,116,255,255,255
012,D,038,032,000,002,000,001,000,000
013,@D , 013,000,001,050,050,105,105,004,004,064,255,000,001,091,255,255,255,10 6,255,255,255,255,091,255,255,255

According to a hex editor each line ends with a hex 0D 0A.

I can index into this file searching for items such as 012,D or 011,@D.
 $a = index($data, "011,[EMAIL PROTECTED]");

 What I need to do once the line is found is to isolate that one line.

A possible idiom is:

   my @lines  = <>; # slurp all lines
   my @wanted = grep { m'012,D|011,@D' } @lines;

If the file is too big:

   my @wanted = ();
   while (my $line = <>) {
       push @wanted, $line if $line =~ m'012,D|011,@D';
   }

You get the idea.

-- fxn

PS: Untested examples.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to