Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Error in my Regular expression pattern

by NetWallah (Abbot)
on Mar 18, 2012 at 15:48 UTC ( #960293=note: print w/replies, xml ) Need Help??


in reply to Error in my Regular expression pattern

Here is the "canonical" way of counting matches into a scalar:
~$ perl -e 'my $x=()="Twinkle twinkle little star"=~/twinkle/ig; print + qq|$x\n|' 2
Note the use of () as an intermediate to switch between scalar and list contexts.
I Sympathize because I too had trouble wrapping my head around this.

             All great truths begin as blasphemies.
                   ― George Bernard Shaw, writer, Nobel laureate (1856-1950)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://960293]
help
Chatterbox?
thezip is randomly reminded of Hugo's_house_of_ho rrors
[LanX]: such much?

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2017-03-24 18:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (305 votes). Check out past polls.