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

Re^3: Word frequency in an array

by cool (Scribe)
on Jun 10, 2007 at 19:03 UTC ( #620345=note: print w/replies, xml ) Need Help??

in reply to Re^2: Word frequency in an array
in thread Word frequency in an array

Hi Dave,

Thanks for giving insight of the solutions and giving me prototypes to copy and paste ;)

And the other problem is that $& only shows the actual most recent match, not some count of the number of possible times

Actually that is what I mentioned pl read comments in

#! /usr/bin/perl use strict; use warnings; my $x=1; my @arr= qw(foo cho roh foo kho foo moo foo); my $str=join ' ',@arr; $str=~ /foo/; print $&; #### In place of $&; we can use that for no #### for no. of matches.
Now, I posted this piece to get suggestion from people, what in regular expression can be used (in place of $&) But it can be done using spl variable of reg ex also, if I am right?? Any takers?

to count the no of matches in one go using special variable, if there is any!! and I think I encountered that somewhere!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-04-03 12:03 GMT
Find Nodes?
    Voting Booth?
    The most amusing oxymoron is:

    Results (27 votes). Check out past polls.