Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: convert rows to columns

by ack (Deacon)
on Nov 26, 2012 at 20:30 UTC ( [id://1005757]=note: print w/replies, xml ) Need Help??


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

I assume in the second line of your "while" loop that you meant @pairs =~ /(..)/g; right?

ack Albuquerque, NM

Replies are listed 'Best First'.
Re^3: convert rows to columns
by Athanasius (Archbishop) on Nov 27, 2012 at 01:43 UTC

    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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1005757]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-03-19 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found