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

Re: Capturing occurrence counts via tr/// with variable interpolation

by Roger (Parson)
on Aug 15, 2005 at 13:49 UTC ( #483853=note: print w/replies, xml ) Need Help??


in reply to Capturing occurrence counts via tr/// with variable interpolation

Use $ans = @{[ $str =~ m/$SrchStr/g ]}; and forget about using eval.

Your $SrchStr, say, if want to find occurances of 'a' and 'z', should be "[az]".

Replies are listed 'Best First'.
Re^2: Capturing occurrence counts via tr/// with variable interpolation
by Roy Johnson (Monsignor) on Aug 15, 2005 at 14:03 UTC
    The other idiom for getting the count from m// is
    $ans = () = $str =~ m/$SrchStr/g;

    Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-12-10 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?