in reply to UTF8 matches

Check if the match fails. $& and the other magic regex variables aren't cleared on failure:
my $foo = "bar"; $foo =~ /ar/; print "Got $&!\n"; $foo =~ /az/; print "Got $&!\n";
Throw an if block or an and in there and you'll be set:
if ($foo =~ /ar/) { print "Got $&!\n"; } $foo =~ /az/ and print "Got $&!\n";

Replies are listed 'Best First'.
Re: Re: UTF8 matches
by Anonymous Monk on Aug 23, 2001 at 01:48 UTC
    Thanks for your input. I guess I should have given more description. I tried
    if ( $str_read_buf =~ m/^\X/ ) { # do success stuff } else { # fail stuff # processing never gets here }
    , but an error was never detected. The m/\X/ detects the invalid byte, because it returns displays the malformed character message, but did not fail. I should have mentioned that this is version 5.6.1.