in reply to Re: Re: Re: Re: reading certain lines
in thread reading certain lines

It was $str = qq/ stuff /; a string in double quote.
  • Comment on Re: Re: Re: Re: Re: reading certain lines

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: reading certain lines
by harry34 (Sexton) on Jun 26, 2003 at 14:05 UTC
    sorry I read it wrong
    but can I automatically open the file (using code below) and read in the strings using the pattern you have provided ?
    e.g using
    $in_filename = "test.out"; open (IN,"$in_filename") or die "Can't open $in_filename:$!\n";
    I need code which will be general, I do not wish to write the stings in my program.
    thanks harry
      Try this:
      use strict; use warnings; # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - my $in_filename = "test.out"; open (IN,"$in_filename") or die "Can't open $in_filename:$!\n"; local $/ = undef; # undef record seperator my $str = <IN>; # read file into string close(IN); # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - my @match = ($str =~ /([A-Z]\s\d+,\s\d+\(\s*\d+\))/g); print "$_\n" for @match;