in reply to passing parameters from shell script to perl program doesn't preserve spaces [solved]
If you put double quotes around the environment variable, its spaces will be preserved.
X='"a b" "c d" e' ; perl -e'for( @ARGV ) { print( "$_\n" ) } ;' "$X"You can then parse each argument.
X='"a b" "c d" e' ; perl -e'for( @ARGV ) { print "$1\n" while /\G\s*("[^"]*"|\S+)/gc } ;' "$X"
|
|---|