in reply to Re^2: Word incidence count
in thread Word incidence count

my @words = /\w+/g;
Shouldn't that be @words =~ /\w+/g; ?
No. But indeed it is implictly assuming that the string to be matched is in $_ which is where it usually is in my code, but which is not the case for the OP's example, actually. But the cure is really lightweight, however:
@words = $string =~ /\w+/g;
Which of them is faster depends on the data.
Please note that I didn't speak of speed. I was talking about the conceptual terseness of the concept of saying what it is that you want as opposed to that of saying what it is that is not among the stuff that you do not want.

Replies are listed 'Best First'.
Re^4: Word incidence count
by holli (Abbot) on May 17, 2005 at 08:42 UTC
    No. But indeed it is implictly assuming that the string to be matched is in $_ which is where it usually is in my code, but which is not the case for the OP's example, actually. But the cure is really lightweight, however:
    Yes of course. My bad.


    holli, /regexed monk/