On Sat, Apr 06, 2002 at 11:32:01PM -0800, John W. Krahn wrote:

> And if you really want to get cute you can put it all on one line:
> 
> substr( $ARGV[0], $_, 1 ) eq $ARGV[1] and $cnt++ for 0 .. length(
> $ARGV[0] ) - 1;
> print $cnt;

I count two lines ;-)

Both of these are a little obfuscated, but show useful techniques:

$ perl -e 'print eval "\$ARGV[0] =~ y/$ARGV[1]//"' q,w,e,r,t,y ,
5
$ perl -e 'print scalar (() = $ARGV[0] =~ /$ARGV[1]/g)' q,w,e,r,t,y ,
5

But this is neither fwp nor golf.

> :-)

Quite :-)

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to