The -s switch is a little problematic on Win32, at least with AS 5.6. perl -s script -VAR=1 works fine but without the -s on the command line (ie with #!perl -s) it does not work. In other words it seems to me that while -w is read off the shebang on Win32 -s is not. Anyway -s implements a very simple mechanism. I would suggest using one of the Getopt modules is a better way to go but you can fake its behaviour with a handful of lines:
C:\>type test.pl #!/usr/bin/perl use strict; our ( $HELLO, $WORLD ); # fake the behaviour of -s { no strict; my @other = (); while(my $term = shift @ARGV) { $term =~ s/^\-/\$/ ? eval $term : push @other, $term; } @ARGV = @other; } print "Got $HELLO $WORLD\n"; print "\@ARGV = ( @ARGV )\n"; C:\>perl test.pl -HELLO=hello -WORLD=world other arguments Got hello world @ARGV = ( other arguments )
Note that this code does a trusting string eval which is dangerous but on Win32 your security is already shot ;-). You should probably make it more secure by validating the $term string before the eval but as whoever executes it already has a shell in which to execute arbitrary commands (and the script will exec with their perms) I don't really see it as a major security issue.
cheers
tachyon
In reply to Re: perl2exe with -s
by tachyon
in thread perl2exe with -s
by Scarborough
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |