in reply to I am geting an unhelpful error message. Not sure how to debug it.

The proper syntax for the "foreach" (aka "for") is:
for my $a ( @line ) { .. Your code here }
the "my $a" declares a locally scoped variable $a, that will be aliased to each element in @line.

You also need to fix your OPEN statement - good practice requires it to use 3 parameters, and provide graceful exit in the event of failure.

Onec you "open" successfully (and get a file handle), you need to use a mechanism to read each line of the file , using the file handle you obtained.
All this is well documented in the fine manual, which includes examples.

As a further comment on what you are attempting: when you read a file a line at a time, you normally place the data you get into a scalar.
Your attempt to use @line to iterate over a single line will meet with (or possibly have already encountered) futility.
Another hint: the "for" loop is not a good way to read all the records in a file - the more traditional way is to use a "while" loop.

             I hope life isn't a big joke, because I don't get it.
                   -SNL

  • Comment on Re: I am geting an unhelpful error message. Not sure how to debug it.
  • Download Code