This is an example from some code I wrote to read in a MS file that had a superfluous BOM.
my @file;
{
my $lh;
open($lh, "<:utf8:crlf", $LogFn) || do {
Pe "\nlogfile <%s> not found", $LogFn;
help;
};
@file = grep {
s/([^\r]+)$/$1/;
m{^\s*$} ? undef : $_;
} <$lh>;
close $lh;
}
$file[0] =~ s/^\N{U+FEFF}//; # UTF-8 BOM
The stuff immediately after the open was to remove the carriage returns, so I could have normal unix line endings.
"Pe", BTW is part of "P". From what I understand, in newer perls, a new keyword, "err" is weaker version of the same (doesn't allow a format statement).
Hope this is of use.
|