Char-UTF2
view release on metacpan or search on metacpan
lib/UTF2.pm view on Meta::CPAN
and rewrite "use $package;" to "use @{[__PACKAGE__]}::$package;" of script "$0".
END
}
# P.302 Module Privacy and the Exporter
# in Chapter 11: Modules
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
#
# A module can do anything it jolly well pleases when it's used, since use just
# calls the ordinary import method for the module, and you can define that
# method to do anything you like.
# P.406 Module Privacy and the Exporter
# in Chapter 11: Modules
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
#
# A module can do anything it jolly well pleases when it's used, since use just
# calls the ordinary import method for the module, and you can define that
# method to do anything you like.
sub import {
if (-e("$filename.e")) {
if (exists $ENV{'CHAR_DEBUG'}) {
unlink "$filename.e";
}
elsif (-z("$filename.e")) {
unlink "$filename.e";
}
else {
#----------------------------------------------------
# older >
# newer >>>>>
#----------------------------------------------------
# Filter >
# Source >>>>>
# Escape >>> needs re-escape (Source was changed)
#
# Filter >>>
# Source >>>>>
# Escape > needs re-escape (Source was changed)
#
# Filter >>>>>
# Source >>>
# Escape > needs re-escape (Source was changed)
#
# Filter >>>>>
# Source >
# Escape >>> needs re-escape (Filter was changed)
#
# Filter >
# Source >>>
# Escape >>>>> executable without re-escape
#
# Filter >>>
# Source >
# Escape >>>>> executable without re-escape
#----------------------------------------------------
my $mtime_filter = (stat(__FILE__ ))[9];
my $mtime_source = (stat($filename ))[9];
my $mtime_escape = (stat("$filename.e"))[9];
if (($mtime_escape < $mtime_source) or ($mtime_escape < $mtime_filter)) {
unlink "$filename.e";
}
}
}
if (not -e("$filename.e")) {
my $fh = gensym();
Eutf2::_open_a($fh, "$filename.e") or die __FILE__, ": Can't write open file: $filename.e\n";
# 7.19. Flushing Output
# in Chapter 7. File Access
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
select((select($fh), $|=1)[0]);
if (0) {
}
elsif (exists $ENV{'CHAR_NONBLOCK'}) {
# P.419 File Locking
# in Chapter 16: Interprocess Communication
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
# P.524 File Locking
# in Chapter 15: Interprocess Communication
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
# P.571 Handling Race Conditions
# in Chapter 23: Security
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
# P.663 Handling Race Conditions
# in Chapter 20: Security
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
# (and so on)
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) };
if ($@) {
die __FILE__, ": Can't immediately write-lock the file: $filename.e\n";
}
}
else {
CORE::eval q{ flock($fh, LOCK_EX) };
}
CORE::eval q{ truncate($fh, 0) };
seek($fh, 0, 0) or die __FILE__, ": Can't seek file: $filename.e\n";
my $e_script = UTF2::escape_script($filename);
print {$fh} $e_script;
my $mode = (stat($filename))[2] & 0777;
chmod $mode, "$filename.e";
close($fh) or die "Can't close file: $filename.e: $!";
}
my $fh = gensym();
Eutf2::_open_r($fh, "$filename.e") or die __FILE__, ": Can't read open file: $filename.e\n";
if (0) {
}
elsif (exists $ENV{'CHAR_NONBLOCK'}) {
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) };
if ($@) {
die __FILE__, ": Can't immediately read-lock the file: $filename.e\n";
}
}
else {
CORE::eval q{ flock($fh, LOCK_SH) };
}
my @switch = ();
if ($^W) {
push @switch, '-w';
}
if (defined $^I) {
push @switch, '-i' . $^I;
undef $^I;
}
# P.707 29.2.33. exec
# in Chapter 29: Functions
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
#
# If there is more than one argument in LIST, or if LIST is an array with more
# than one value, the system shell will never be used. This also bypasses any
# shell processing of the command. The presence or absence of metacharacters in
# the arguments doesn't affect this list-triggered behavior, which makes it the
# preferred from in security-conscious programs that do not with to expose
# themselves to potential shell escapes.
# Environment variable PERL5SHELL(Microsoft ports only) will never be used, too.
# P.855 exec
# in Chapter 27: Functions
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
#
# If there is more than one argument in LIST, or if LIST is an array with more
# than one value, the system shell will never be used. This also bypasses any
# shell processing of the command. The presence or absence of metacharacters in
# the arguments doesn't affect this list-triggered behavior, which makes it the
# preferred from in security-conscious programs that do not wish to expose
# themselves to injection attacks via shell escapes.
# Environment variable PERL5SHELL(Microsoft ports only) will never be used, too.
# P.489 #! and Quoting on Non-Unix Systems
# in Chapter 19: The Command-Line Interface
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
# P.578 #! and Quoting on Non-Unix Systems
# in Chapter 17: The Command-Line Interface
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
( run in 1.886 second using v1.01-cache-2.11-cpan-39bf76dae61 )