📄 runperl.pl
字号:
#!perl -w$0 =~ s|\.bat||i;unless (-f $0) { $0 =~ s|.*[/\\]||; for (".", split ';', $ENV{PATH}) { $_ = "." if $_ eq ""; $0 = "$_/$0" , goto doit if -f "$_/$0"; } die "`$0' not found.\n";}doit: exec "perl", "-x", $0, @ARGV;die "Failed to exec `$0': $!";__END__=head1 NAMErunperl.bat - "universal" batch file to run perl scripts=head1 SYNOPSIS C:\> copy runperl.bat foo.bat C:\> foo [..runs the perl script `foo'..] C:\> foo.bat [..runs the perl script `foo'..] =head1 DESCRIPTIONThis file can be copied to any file name ending in the ".bat" suffix.When executed on a DOS-like operating system, it will invoke the perlscript of the same name, but without the ".bat" suffix. It willlook for the script in the same directory as itself, and then inthe current directory, and then search the directories in your PATH.It relies on the C<exec()> operator, so you will need to make surethat works in your perl.This method of invoking perl scripts has some advantages overbatch-file wrappers like C<pl2bat.bat>: it avoids duplicationof all the code; it ensures C<$0> contains the same name as theexecuting file, without any egregious ".bat" suffix; it allowsyou to separate your perl scripts from the wrapper used torun them; since the wrapper is generic, you can use symboliclinks to simply link to C<runperl.bat>, if you are serving yourfiles on a filesystem that supports that.On the other hand, if the batch file is invoked with the ".bat"suffix, it does an extra C<exec()>. This may be a performanceissue. You can avoid this by running it without specifyingthe ".bat" suffix.Perl is invoked with the -x flag, so the script must containa C<#!perl> line. Any flags found on that line will be honored.=head1 BUGSPerl is invoked with the -S flag, so it will search the PATH to findthe script. This may have undesirable effects.=head1 SEE ALSOperl, perlwin32, pl2bat.bat=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -