Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Do not understand code

by Your Mother (Archbishop)
on Oct 02, 2017 at 12:56 UTC ( [id://1200519]=note: print w/replies, xml ) Need Help??


in reply to Re: Do not understand code
in thread Do not understand code

the then-present value of a variable, $_, which the Perl language does not even name.

I was curious if this was true, so checked English. Interestingly, to me at least, it does have a name but I admit its name is barely any better than not having one at all and probably why I didn't already know the answer without needing to look–

perl -MEnglish -le '$_ = "moo"; print $ARG' moo

Replies are listed 'Best First'.
Re^3: Do not understand code
by eyepopslikeamosquito (Archbishop) on Oct 03, 2017 at 09:27 UTC

    I'm worried that this talk of translating $_ into English is neglecting the all-important needs of the Perl poet, specifically the crucial Perl haiku (5-7-5) syllable count, where traditionally $_ is pronounced as "it" and @_ as "them", as in chipmunk's winning TPC 4 poem (where his subroutine summer is both a "sum-er" and a season):

    sub summer { my $sum; $sum += $_ for @_; $sum } print summer (split);
    and is pronounced (5-7-5) like so:

    sub sum-mer my sum
    sum plus equ-als "it" for "them"
    sum print sum-mer split

      the crucial Perl haiku (5-7-5) syllable count

      Far from crucial, the 5-7-5 syllable count is unnecessary. The idea that it's central to the definition of haiku is bogus. Pure myth.

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
Re^3: Do not understand code
by Eily (Monsignor) on Oct 02, 2017 at 16:09 UTC

    Actually I would expect $ARGV for $_ to mostly be a side effect of @ARGV for @_. This also works for other punctuation variables and their english versions

    perl -MEnglish -E "@; = q<Hi>; say @SUBSEP" Hi
    It's not a name that perl parses, but I'd expect pretty much everyone here to understand what "the default variable" refers too.

      > to understand what "the default variable" refers too.

      We could consider adding $DEF or $DEFAULT for $_ to Perl.

      > @; = q<Hi>; say @SUBSEP

      I suppose these are just glob aliases, that's why they work for all types associated to a symbol.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        I suppose these are just glob aliases, that's why they work for all types associated to a symbol.
        Yup, as confirmed by reading the code for English. @- and $- have different names though, so only the ARRAY and SCALAR portion of the glob are used in those cases.

        I was about to say that if you want to have a longer name instead of $_ you can just use a lexical instead (I was thinking of for loops), but I forgot about grep and map where you have to use $_. $CURRENT would work in those cases.

Re^3: Do not understand code
by LanX (Saint) on Oct 02, 2017 at 16:19 UTC
    It takes too much energy correcting all inaccuracies in sundial posts in replies. *

    If it was possible to edit foreign posts (like in SO), sundials would be normally full of strikes and red comments.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    *) that's the DOS feature which makes him similar to trolls.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found