Daniel Gardner wrote: > > >> > >> Why slow it down with the 'i'? > >> $searchstring=~/[a-zA-Z0-9]/; > > > Why slow it down with a regular expression? :-) > > > if ( $searchstring =~ tr/a-zA-Z0-9// ) { > > i was bored, and thought i'd try a little benchmark. note, this > is for the specific problem expressed here, not the general case. > > i benchmarked the following: > > RegexWithI: $string =~ /[A-Z0-9]/i; > RegexNoI: $string =~ /A-Za-z0-9/; > tr: $string =~ tr/[A-Za-z0-9//; > > [snip benchmark results] > > #!/usr/bin/perl -w > > [snip code] > > sub with_i { > my ($string) = @_; > $string =~ /[A-Z0-9]/i; > } > sub without_i { > my ($string) = @_; > $string =~ /[A-Za-z0-9]/; > } > sub tr_without { > my ($string) = @_; > $string =~ tr/[A-Za-z0-9]//; > }
Note that the tr/// is looking for the characters '[', 'A-Z', 'a-z', '0-9', and ']' while the m// is not looking for the '[' and ']' characters so they are not equivalent. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]