in reply to Take in command line arguments as an entire string?
G'day proxie,
See the special variable $" (aka $LIST_SEPARATOR). Some examples:
$ perl -le 'print @ARGV' foo1 foo2 foo3 foo1foo2foo3 $ perl -le 'print "@ARGV"' foo1 foo2 foo3 foo1 foo2 foo3 $ perl -le 'local $" = "~"; print @ARGV' foo1 foo2 foo3 foo1foo2foo3 $ perl -le 'local $" = "~"; print "@ARGV"' foo1 foo2 foo3 foo1~foo2~foo3
If you want to change the value of $", or indeed any special variable, you'd be well advised to use local. It might be considered overkill in little one-liner such as I have there, but it's a good habit to get into. In an actual script, I'd recommend doing it always.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Take in command line arguments as an entire string?
by LanX (Saint) on Aug 22, 2018 at 06:28 UTC | |
by kcott (Archbishop) on Sep 06, 2018 at 07:48 UTC |