Perl preamble that will run under Windows or Linux
linux, perl, shell, windows
Solution
I doubt that you can get windows to accept a shbang (`#!`). So if you can run with the default shell (in my case bash), then this works in bash:
@REM <<:END_REM
@echo off
echo This is DOS, this will only run in DOS.
perl -x -S %0 %*
goto over_nix
:END_REM
echo This is *NIX, this will only run in *NIX.
perl -x -S $0 $*
:<<__END__
#!perl
use 5.012;
use Data::Dumper;
say Dumper( \%ENV );
__END__
@REM <<:over_nix
:over_nix
This required an executable in my NIX path called `'@REM'`.
echo >> ~/bin/@REM
chmod +x ~/bin/@REM
Problem
Is there any single magic "preamble" that will make a Perl script run under Windows (as a batch file) or Linux (as an executable file), similar to the preambles out there that make it work under any shell?