Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Why is this auto-quoted?

by Anonymous Monk
on Jul 31, 2013 at 03:39 UTC ( [id://1047163]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Why is this auto-quoted?
in thread Why is this auto-quoted?

Not really quit!

You know what the difference between -'foo' and '-foo' is? nothing

Replies are listed 'Best First'.
Re^4: Why is this auto-quoted?
by QM (Parson) on Jul 31, 2013 at 08:45 UTC
    You know what the difference between -'foo' and '-foo' is? nothing
    Interesting to note that -'foo' and -'+foo' deparse to the same thing, -'foo'. This could be a gotcha if you needed the + sign.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      This could be a gotcha if you needed the + sign.

      Sure, but why use the - in that case?

      :) see Re: Why is this auto-quoted? (because) and perlglossary#identifier and nans, infs, and vomit

      $ perl -wle " print +foo" Unquoted string "foo" may clash with future reserved word at -e line 1 +. Name "main::foo" used only once: possible typo at -e line 1. print() on unopened filehandle foo at -e line 1. $ perl -wle " print -+foo" Unquoted string "foo" may clash with future reserved word at -e line 1 +. -foo $ perl -wle " print -'+foo'" -foo $ perl -wle " print -(-foo)" +foo

        This also works:

        $perl -wle " print - -foo " +foo

        The space between the two minus signs is significant; otherwise Perl thinks you're trying to decrement a constant.

        Also:

        $perl -wle " print -+-foo " +foo $perl -wle " print +-+-foo " +foo $perl -wle " print -+-+-foo " -foo $perl -wle " print +-+-+-foo " -foo $perl -wle " print -+-+-+-foo " +foo $perl -wle " print +-+-+-+-foo " +foo

        ...etc

        package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
        Sure, but why use the - in that case?
        You may not know there is a + there, as in an eval or "$interpolation".

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 00:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found