in reply to Perl Idioms Explained - my $count = () = /.../g
Just to have it mentioned: another way to do it is given in perldoc -f scalar:
Personally, I think this makes the meaning clearer, but I'm sure others may disagree.#!perl -l my $str = "here are some words"; my $count = @{[ $str =~ /\S+/g ]}; print $count;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl Idioms Explained - my $count = () = /.../g
by japhy (Canon) on Feb 07, 2006 at 15:40 UTC |
In Section
Meditations