[Israel.pm] new module for CPAN: Getopt::Long::String

Jason Elbaum jason.elbaum at gmail.com
Sun Jan 29 23:51:38 PST 2006


>         my @_ARGV = @ARGV;
>         @ARGV = split /\s+/, shift;

There's another problem with this code. It doesn't parse the command
line the way the shell does. The shell has special processing for
quoted strings, stripping the quotes and making each quoted string
into a single argument. Thus, this command line:

mail -s 'some subject line' -f "Funny File Name.txt"

becomes this @ARGV:

( 'mail', '-s', 'some subject line', '-f', 'Funny File Name.txt' )

Simply splitting on whitespace, however, yields:

( 'mail', '-s', '\'some', 'subject', 'line\'', '-f', '"Funny', 'File',
'Name.txt"' )

which is not at all what was intended.

Jason Elbaum
jason.elbaum at gmail.com




More information about the Perl mailing list