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

Re: Yet another array problem

by 5mi11er (Deacon)
on Jul 29, 2005 at 16:30 UTC ( [id://479471]=note: print w/replies, xml ) Need Help??


in reply to Yet another array problem

From the line immediately following your commented line "#this works", you attempt to overwrite your array @line1 by splitting the numbers out of @line1, except you've forgotten to specify that you want it to operate on @line1, so instead it's operating on $_.

So, not only is it operating on the wrong variable, it also destroys the array that had the correct information. Overwriting variables like this is not generally a good idea.

If you don't need the intermediate result learn how to chain the operations together, or how to dereference things correctly. I'd suggest placing the data read from the file into a two dimensional array as you're reading it in, rather than keeping the lines as they were read, and then later attempting to split everything out.

-Scott

Replies are listed 'Best First'.
Re^2: Yet another array problem
by Angharad (Pilgrim) on Jul 29, 2005 at 17:26 UTC
    Thanks for the tip.

Log In?
Username:
Password:

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

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

    No recent polls found