in reply to Parsing a file
Which is one problem, and another is you're using the regex anchor \A which matches the beginning of a string. So you're matching berta226: to the beginning of the string, which will also make the regex fail. If you change your code to something like this you should get the desired output (updated - dropped extraneous semi-colon on second line. update 2: also fixed a further 2 mistakes as noted below .oO(note to self - don't post in a hurry shortly before leaving ... ))while(<FILE>) { ## assign $_ to readline *FILE my $message = <FILE>; ## assign my $message to readline *FILE
See. perlsyn and perlre for more info.while(my $message = <FILE>) { print "$1: $2<br/>" if $message =~ /^(Alberta226: )([a-zA-Z, 0-9]+)/; # I added the + }
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Parsing a file
by sulfericacid (Deacon) on Jan 23, 2004 at 07:35 UTC | |
|
Re: Re: Parsing a file
by Anonymous Monk on Jan 22, 2004 at 19:20 UTC | |
by ysth (Canon) on Jan 22, 2004 at 19:38 UTC | |
|
Re: Re: Parsing a file
by Anonymous Monk on Jan 22, 2004 at 20:16 UTC | |
by Nkuvu (Priest) on Jan 22, 2004 at 20:27 UTC |