You can also use this bizarre construction to capture just the count:
$_ = ABabcde12345BAABabcde1234blahblah5BA;
$count = () = $_=~ /(AB.*?BA)/g;
print I matched $count times\n'
the () between the two ='s forces the match to list context, and then
THAT is forced to scalar context by
If you're using ActiveState Perl, an easy was is to use the wperl
executable instead of the perl executable to run your scripts.
Scripts you want to run w/o the dos box could have a .wpl extension
instead of .pl, and you could associate .wpl with wperl.
--Kester Allen
On Wed, 15 Dec 2004 13:38
There's a fun little idiom using tr/// to count the number of
occurances of a character in a string:
perl -le '$str = a,b,c,d,e; $count = ($str =~ tr/,/,/); print $count'
will output 4, the number of commas in a,b,c,d,e.
--Kester
Jeff Williams wrote, on Tue 12/14/2004 11:23
: I wrote a
obliged.
Thank you,
Kester Allen
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs