Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: storing string matched by regular expression

by vladb (Vicar)
on Jun 27, 2002 at 14:33 UTC ( [id://177717]=note: print w/replies, xml ) Need Help??


in reply to storing string matched by regular expression

Yes, I've got an idea ;).
($thisresult) = ($teststring =~ /[aft][edt].[ftg]...v{2,3}/g); if ($thisresult) { if (!$lastresult) { print "Expression found\n"; } } $lastresult = $thisresult;
Notice, I simply placed your $thisresult variable inside a pair of (). This is required as the regexpt would return array of matched values in list context. Previously, you were invoking regexp in 'scalar' context, which only gets you the total count of matches found.

Update: fixed code (saw the correct version after the original node was edited).

_____________________
# Under Construction

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found