#!/usr/bin/perl -T use strict; use CGI; use Encode; my $c = new CGI; my @menu_choices = ( "\x{03a6}\x{03a5}", "\x{03b2}\x{03c1}" ); binmode STDOUT, ":utf8"; print $c->header, $c->start_html; print $c->h3("(Display should be readable as utf8)"), $c->h3("\x{0395}\x{03c0}\x{03ad}\x{03bb}\x{03b5}\x{03be}\x{03b5}"); if ( $c->param( 'select' )) { # use bytes; # my $val = $c->param('select'); my $val = decode( 'utf8', $c->param( 'select' )); my $match = ( grep /^$val$/, @menu_choices ) ? "matches" : "fails to match"; printf "

The value %s received from the form has length %d, and %s.

", $val, length( $val ), $match; } print $c->start_form, $c->popup_menu( -name => 'select', -values => \@menu_choices ), $c->submit( 'ok' ); $c->end_form; print $c->end_html; exit;