On Thu, Jan 24, 2002 at 11:30:58AM -0500, Uri Guttman wrote:
> >>>>> "B-J" == Bill -OSX- Jones <[EMAIL PROTECTED]> writes:
> 
>   >> To do... what?
> 
>   B-J> $_ = "Mac OS X";
> 
>   B-J> split //;
>   B-J> $c = grep {/[osx]/i} @_;
> 
>   B-J> print "Found $c things\n";
> 
> still not clear. try expressing it in english.
> 
> but tr/// is the fastest way to count chars which is what you seem to be
> doing.
> 
>       $_ = "Mac OS X";
> 
>       $c = tr/osxOSX// ;


I'd rather write that as:

        $c = lc =~ tr/osx//;


Speed isn't an issue, if you need to count chars in the same string
in a loop, you'd cache the result anyway. And not having to copy
the letters is less error prone and saves typing. Specially if you have
a large set of characters.



Abigail

Reply via email to