Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi there, I am fairly new to PERL, just the intro course under my belt. I use the Regex coach for help with this, but my output is not as I expect. I am reading lines like the one below and am trying to extract the three prices into $1, $2 and $3. "18-December-09";"$1,104.50 ";"29-July-97";"$326.55 ";"25-April-85";"$322.50 "; Any and all help appreciated.
while(<$in_fh>) { my $line = $_; if ( $line =~ m[(\$\d?,?\d\d\d\.\d\d\b){3}] ) { print "$1"; print "$2"; print "$3"; $ctr ++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why is my regex not right?
by toolic (Bishop) on Jul 18, 2011 at 13:59 UTC | |
|
Re: why is my regex not right?
by JavaFan (Canon) on Jul 18, 2011 at 13:55 UTC | |
|
Re: why is my regex not right?
by Jim (Curate) on Jul 18, 2011 at 18:41 UTC |