Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: convert rows to columns

by Athanasius (Canon)
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

Comment on Re^3: convert rows to columns
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2015-12-01 15:52 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (16 votes), past polls