# assume that "$octets" is the string that has been recieved # from a form, and is purported to be utf8 text: ... use Encode; ... my $utf8str; eval "\$utf8str = encode( 'utf8', \$octets, Encode::FB_CROAK )"; if ( $@ ) { # $octets was not really a valid utf8 string } ...