in reply to Regex for Differentiating Underscore and Whitespace

How about transliteration?

if( $str =~ tr/_/_/ ) { print "with underscore\n"; } else { print "no underscore\n"; }

Or just for fun...

my $result = ( $str =~ tr/_/_/ ) ? "with " : "no "; print "$result underscore\n";

perlop explains the use of the tr/// operator.


Dave