Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Help with a more precise regex

by Ovid (Cardinal)
on Apr 25, 2003 at 19:53 UTC ( [id://253229]=note: print w/replies, xml ) Need Help??


in reply to Help with a more precise regex

I think I might be misunderstanding the problem because it seems straightforward:

foreach (<DATA>) { my ($day) = /(\d+)d/; my ($hour) = /(\d+)h/; $_ ||= 0 foreach $day, $hour; print "Day: ($day) Hour: ($hour)\n"; } __DATA__ 3d 3d 2h 6h

The prints:

Day: (3) Hour: (0)
Day: (3) Hour: (2)
Day: (0) Hour: (6)

Cheers,
Ovid

New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)

Replies are listed 'Best First'.
Re:^2 Help with a more precise regex
by LogicalChaos (Beadle) on Apr 25, 2003 at 20:02 UTC
    Duh, I couldn't see the trees for the regex forest I had created...

    Thanks for your clear thinking Ovid.

    LogicalChaos
Re: Re: Help with a more precise regex
by Nkuvu (Priest) on Apr 25, 2003 at 20:02 UTC

    *snif* That's beautiful!

    I regret that I have only one ++ vote to give to this note...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found