Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: newline behavior in Regular Expression

by qq (Hermit)
on Apr 12, 2004 at 21:15 UTC ( #344528=note: print w/replies, xml ) Need Help??


in reply to Re: newline behavior in Regular Expression
in thread newline behavior in Regular Expression

I agree, eval seems unneeded here. You can still use s///, although I would prefer it like yours.

#!/usr/bin/perl my $x = "Line1\nLine2Resolved 200 problems out of 5000 picked\nLine4\n +Line5"; $x =~ s/.*?Resolved (\d+) problems out of (\d+) picked.*/ ($2 - ($1\/$2)) > .5 ? 1 : 0 /es; print "$x\n";

Remember to escape the division in the substitution.

qq

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-10-24 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?