Skip to content

Instantly share code, notes, and snippets.

@mrballcb
Created January 14, 2014 13:18
Show Gist options
  • Save mrballcb/8418172 to your computer and use it in GitHub Desktop.
Save mrballcb/8418172 to your computer and use it in GitHub Desktop.
A perl addition to detect and re-exec itself if PERL_UNICODE env var is set. The var causes STDIN/STDOUT/STDERR to be read as multibyte utf-8 chars instead of just single byte ascii chars. This is useful when operations such as m// or s/// are looking for hex bytes, such as: $line =~ s/\x{e2}\x{94}[\x{8c}-\x{bf}]/+/g;
if (defined $ENV{'PERL_UNICODE'})
{
delete $ENV{'PERL_UNICODE'};
exec ($0, @ARGV);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment