Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: convert rows to columns

by Athanasius (Chancellor)
on Nov 27, 2012 at 01:43 UTC ( #1005778=note: print w/replies, xml ) Need Help??


in reply to Re^2: convert rows to columns
in thread convert rows to columns

No, I did mean =, for assignment.

On each iteration of the while loop, the default variable $_ is implicitly assigned the next line read from the DATA handle. This $_ variable becomes the implicit argument to chomp, and then it’s implicitly bound to the regex match.

So, the code I gave is equivalent to this:

while ($_ = <DATA>) { chomp $_; my @pairs = $_ =~ /(..)/g; ...

but more compact and “Perlish”. See perlvar#General-Variables.

Hope that helps,

Athanasius <°(((><contra mundum

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005778]
help
Chatterbox?
[ambrus]: Today I accidentally cut my hand while carrying a computer. On the display part of the motherboard that sticks out at the back of the chasis and has ports, there's this thin metal sheet with holes cut for the ports, to guide plugs into the sockets.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2017-01-16 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (151 votes). Check out past polls.