in reply to one liner error

Further to Athanasius's reply:   If you don't like using quotes on your command line (and who does?), you can, in certain limited cases, avoid them:

c:\@Work\Perl\monks>perl -wMstrict -MCwd -le my$str=getcwd;print(qq{it +\x20is\x20now\x20$str}) it is now c:/@Work/Perl/monks
The trick is that the command(s) must not contain whitespace. Time and effort spent golfing is never wasted!


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: one liner error
by Fletch (Bishop) on May 27, 2020 at 13:55 UTC

    Just to expand for *NIX shells, you need to avoid whitespace and other characters the shell is going to interpret specially: e.g. parens, curlies, braces, splats, dolar signs, ampersands, semicolons, and backslashes (and that's in no ways an exhaustive list). Usually you can backslash them to escape them, but you're going to wind up with leaning toothpick syndrome. It'll be much simpler (to say nothing of fewer characters) if you just break down and (single) quote things and be done with it.

    $ uptime | perl -nE m\{\(load\ averages:.\*\)\}\&\&say\$1 load averages: 1.12 1.02 0.95 $ uptime | perl -nE 'm{(load averages:.*)}&&say$1' load averages: 0.84 0.96 0.93

    (Insert Jurasic Park quote about could versus should)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Simpler? Simpler? I don' need no stinkin' simpler! I've got Windose!


      Give a man a fish:  <%-{-{-{-<

        🤮 poor thing ...
      >Jurasic Park

      It's a UNIX system. You know this. xD

      Also the source of the "hold your butts" meme for when you're deploying something tricky or not well tested...talk about bout an effect on nerd culture.

Re^2: one liner error
by toohoo (Beadle) on May 28, 2020 at 05:45 UTC

    Hi AnomalousMonk,

    ARGH! The Windows space problem. You are right. Sometimes I have known things already that sometimes I forget :-/

    Many thanks to you, you are great.