#!/usr/bin/perl -w use encoding 'utf8'; open IN, '<:utf8', 'debug.txt'; open OUT, '>:utf8', 'debug1.txt'; while () { my @mid = m#START(..)END#; $out = "Middle characters are $mid[0]\n"; $out .= ('Their hex codepoints are ' . ( sprintf '%x %x', (ord $mid[0]), (ord (substr $mid[0], 1)) ) . "\n"); ($out .= "START is there\n") if m#START#; ($out .= "[ff] is there\n") if m#[\xff]#; ($out .= "ff is there\n") if m#\xff#; ($out .= "[{ff}] is there\n") if m#[\x{ff}]#; ($out .= "{ff} is there\n") if m#\x{ff}#; ($out .= "[{00ff}] is there\n") if m#[\x{00ff}]#; ($out .= "{00ff} is there\n") if m#\x{00ff}#; my $xff = (pack 'U', 0xff); ($out .= "pack0xff is there\n") if m#$xff#; ($out .= "[ÿ] is there\n") if m#[ÿ]#; ($out .= "ÿ is there\n") if m#ÿ#; ($out .= "[{0100}] is there\n") if m#[\x{0100}]#; ($out .= "{0100} is there\n") if m#\x{0100}#; my $x100 = (pack 'U', 0x100); ($out .= "pack0x100 is there\n") if m#$x100#; ($out .= "[Ā] is there\n") if m#[Ā]#; ($out .= "Ā is there\n") if m#Ā#; print OUT "$out"; } close IN; close OUT;