I have a perl script test.pl which reads arguments from the command line
#!/usr/bin/perl -w
for( @ARGV ) { print( "$_\n" ) } ;
This works well when I pass parameters like "a b" "c d" e on the command line
The result is:
a b
c d
e
If I declare a variable
X='"a b" "c d" e'
and then run
test.pl $X
I get
"a
b"
"c
d"
e
I need to run the perl script from various shell scripts as a helper function and the parameters are calculated by those scripts.
The parameter count is not fixed so I have to pass it as a list.
Alas I cannot find a way to get the perl program handle my parameters as desired.
I have thought of passing the parameters through file but then the manual invocation of the perl script from the command line becomes awkward.
How can I get the perl script preserve the spaces in the paramters?
perlscript gets saved in@ARGVarraySo when you are printing it gives values from that array and printing it as different arguments given because It does not preserving the space between your arguments, Space is used to identify the different arguments.