Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: converting user friendly regex to perl friendly

by abitkin (Monk)
on Oct 15, 2004 at 17:57 UTC ( #399592=note: print w/replies, xml ) Need Help??


in reply to converting user friendly regex to perl friendly

Why convert it, when you can easily just change it to a set of if statements and eval that?

Note, completely untested code, written from memory

if($_ =~ s/\[(\d+)-(\d+)\]/){ s/\[(\d+)-(\d+)\]/command if(\$x >= $1 && \$x <= $2);/; eval $_; }
Most likely this code won't compile, but it's a starting point.

==
Kwyjibo. A big, dumb, balding North American ape. With no chin.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2020-05-30 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (171 votes). Check out past polls.

    Notices?