in reply to use utf8;

What you want is byte-semantics of your regexp, instead of the char-semantics, which utf8 will force. What you can do is to put 'use utf8' in smaller scopes. For example, in your case, put use utf8 within your while loop, it should then be fine: (This is for unix, if someone is working with activestate Perl 5.8.0, this caution is not neccessary.)
my $hexString = "#00FF00"; my $darkHexString = '#'; while ($hexString =~ m/([0-9a-f]{2})/ig) { use utf8; $darkHexString .= sprintf "%02lx", int(hex($1)/2); } print "$darkHexString\n";

Replies are listed 'Best First'.
Re: Re: use utf8;
by Jaap (Curate) on Nov 28, 2002 at 19:32 UTC
    Is it also possibe to match two hex chars in char-semantics?