# open an euc-jp file: open( $inp, "<:encoding(euc-jp)", "some_file.euc" ) or die "$!"; while (<$inp>) { # data will be decoded on input ... # so $_ will have its utf8 flag "on" and # s///, ord(), etc will use character semantics } # open a utf8 file: open( $inp, "<:utf8", "some_file.utf8" ) or die "$!"; while (<$inp>) { # data will be interpreted as utf8 on input ... # so $_ will have its utf8 flag "on" and... (same as above) }