Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How does $. work in one liner?

by Eily (Monsignor)
on May 28, 2016 at 23:30 UTC ( #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? | Other CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2021-10-16 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (69 votes). Check out past polls.

    Notices?