Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: Error opening file handle within while loop (uninitialized value in array)

by hippo (Bishop)
on Feb 10, 2016 at 13:16 UTC ( [id://1154856]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Error opening file handle within while loop
in thread Error opening file handle within while loop

Since you are new to coding my guess is because @columnsA (or whatever) has only 2 elements while your code thinks there are three. Arrays are indexed from zero upwards, not from one.

  • Comment on Re^5: Error opening file handle within while loop (uninitialized value in array)
  • Download Code

Replies are listed 'Best First'.
Re^6: Error opening file handle within while loop (uninitialized value in array)
by rjc33 (Sexton) on Feb 10, 2016 at 13:25 UTC
    This is a good suggestion, but there should be 7 elements in the array (or 0-6).

      What steps have you undertaken to ascertain your assumption?

      For example, the following prints the number of elements in the array @columns:

      print 0+@columns;

      And the following shows you the values of the elements:

      use Data::Dumper; print Dumper \@columns;

      Personally, I would always look at the line where @columns gets initialized, and also inspect the source data, by printing the line $line1.

        Was just checking, seemed to be a problem with splitting by tab (I thought it was a tab delimited file) rather than whitespace, which fixed it and gave the correct number of elements in the array. All working now, apologies for the collection of simple errors, and thanks for everybody's help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1154856]
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-04-24 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found