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
    Hi Ken,

    You might want to add the $OUTPUT_FIELD_SEPARATOR aka $,

    :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      G'day LanX,

      ++ That's a good point. Thanks.

      And sorry for the late reply. I've had some serious dental issues of late: mostly been drugged up to the eyeballs on strong pain killers.

      — Ken