| [reply] |
/try.pl a|b|c|d
It is unusual to run a script from the root directory, you probably mean: ./try.pl 'a|b|c|d'
but that is a shell question, it has nothing to do with Perl.
| [reply] [d/l] [select] |
The pipe character means something special to your shell: for most, it means to pipe the output of one command to the input of the next. Quote your argument string, eg "a|b". See your shell's documentation for quoting rules and special characters.
| [reply] [d/l] |
/try.pl a|b|c|d
bash: b: command not found
bash: c: command not found
bash: d: command not found
That's an error you're getting due to bash, not Perl. You tell bash to call "/try.pl" with the argument 'a', and pipe the result into b, its result into c, and that result into d.
You probably want /try.pl 'a|b|c|d'. But, we aren't done. Once you have 'a|b|c|d', you feed it back into a shell. So, again, you need to escape it, but putting quotes around $_.
But why are you writing a Perl program which all it does it take input, and feed the input back to another shell? Why not just:
#!/usr/bin/sh
echo $1 > /tmp/gerbil.txt
However, if you do write it in Perl, why both the backticks, and system? Do you even know what the backticks do? Now you are saying: "Perl, please start a shell, and execute the command I'm giving you. Gather the output, and starts a second shell, executing whatever was written to STDOUT by the first shell." Is that really your intention? | [reply] [d/l] [select] |
| [reply] |