Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: $^O empty in windows powershell

by LanX (Saint)
on Nov 22, 2022 at 11:06 UTC ( [id://11148301]=note: print w/replies, xml ) Need Help??


in reply to $^O empty in windows powershell

For a full answer:

PS copied many concepts from Bash and Perl. (After all it's an attempt to fix problems with cmd and bat and full of aliases to support *nix commands)

For instance

  • $ as sigil for $variables
  • interpolation in double-quoted strings

C:\tmp>powershell Windows PowerShell Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten. PS C:\tmp> $x="xxx" PS C:\tmp> echo "a${x}b" axxxb PS C:\tmp> echo 'a${x}b' a${x}b PS C:\tmp> exit C:\tmp>

That's why you need a single-quoted string for perl -e

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: $^O empty in windows powershell
by WithABeard (Sexton) on Nov 22, 2022 at 14:17 UTC

    the following code does not output anything:

    perl -e 'print "this is a test";'

    I can't figure out why, shouldn't this work?

    this works though:

    perl -e 'print qq(this is a test);'
      my guess is that doublequotes are stripped from the input

      PS C:\Windows\system32> perl -E'say @ARGV' 'say "bla"' say bla PS C:\Windows\system32> perl -E'say @ARGV' 'say qq(bla)' say qq(bla) PS C:\Windows\system32> echo 'say "bla"' say "bla" PS C:\Windows\system32> echo 'print "bla"' |perl bla PS C:\Windows\system32> echo 'print "bla"' |perl -E'say <>' print "bla" PS C:\Windows\system32>

      this could be an artifact of Perl trying to repair input from CMD ... (?)

      (I think eyepops will soon come up with an older discussion about the Perl trying to cleverly fix CMD idiosyncrasies ;)

      Cheers Rolf
      (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148301]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-20 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found