Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How does $. work in one liner?

by Eily (Monsignor)
on May 28, 2016 at 23:30 UTC ( [id://1164420]=note: print w/replies, xml ) Need Help??


in reply to How does $. work in one liner?

++AnomalousMonk for the link to the range operator. This is a good example of the perl philosphy of "Do what I mean" which really is "use context to understand what I really meant" as in perl many things work differently depending on context. The .. operator is often better understood in list context @array = 1..10; where it means "all the element from 1 to 10". The construct you have here keeps this "from", "to" meaning, except it makes no sense to generate a list of elements in a single test (scalar, or even more specifically boolean context). So the sense that has been chosen for this test to be true "from 1 to 2" is to compare $. with the values. 1..2 now means "from line 1 to line 2".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found