my $regex = qr/some: (\S+) pattern/si; my $data = Encode::decode(utf8 => $file); do_something($1) if $data =~ $regex; # <- ERROR HAPPENS HERE