mmittiga17 has asked for the wisdom of the Perl Monks concerning the following question:
need to pull just date out of lines. Date is preceded by (PURCHASED ON|SOLD ON|SETTLED ON). example CLASS A SOLD ON 17/11/10 FOR SETTLEMENT ON 22/11/10 @ 145.59993 just want to grab 17/11/10 as $tdate and 22/11/10 as $sdate
Any help will be appreciated.while(defined($line = (<IN>))){ if ($line =~m/(PURCHASED ON|SOLD ON|SETTLEMENT ON)/) { $desc = (split(/\,/, $line))[27]; #print "$desc\n"; $tdate = (($desc =~ /PURCHASED\s+ON\s+(.*?)\s+/g )||($de +sc =~ /SOLD\s+ON\s+(.*?)\s+/g )); $sdate = $desc =~m/SETTLEMENT\S\s+ON\s+(.*?)\s+/g ; print "TDATE $tdate SDATE $sdate\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help with regex
by AnomalousMonk (Archbishop) on Nov 30, 2010 at 00:56 UTC | |
|
Re: help with regex
by toolic (Bishop) on Nov 30, 2010 at 00:36 UTC |