Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: help with regex

by toolic (Bishop)
on Nov 30, 2010 at 00:36 UTC ( [id://874402]=note: print w/replies, xml ) Need Help??


in reply to help with regex

while (<DATA>) { if (/(PURCHASED ON|SOLD ON|SETTLEMENT ON)/) { $desc = $_; if ($desc =~ /SETTLEMENT\s+ON\s+(\S+)/) { $sdate = $1; } if ($desc =~ /(?:PURCHASED|SOLD)\s+ON\s+(\S+)/) { $tdate = $1; } print "TDATE $tdate SDATE $sdate\n"; } } __DATA__ CLASS A SOLD ON 17/11/10 FOR SETTLEMENT ON 22/11/10 @ 145.59993

Prints:

TDATE 17/11/10 SDATE 22/11/10

perlre

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://874402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-19 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found