Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Using a variable to define a variable

by AnomalousMonk (Archbishop)
on May 08, 2015 at 16:01 UTC ( [id://1126115]=note: print w/replies, xml ) Need Help??


in reply to Using a variable to define a variable

A "more Perlish" way to do this is something like (untested):

my @file_line_contents = ...; my @line_lengths = map length($_), @file_line_contents;
See map.

Update: Or if  @file_line_contents is likely to be more than 45 elements and you want the length array to be limited to 45 (untested):

my @file_line_contents = ...; my @line_lengths = map length($_), @file_line_contents[ 0 .. 44 ];
See Slices in perldata.


Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-23 23:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found