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


In reply to Re: I am geting an unhelpful error message. Not sure how to debug it. by NetWallah
in thread I am geting an unhelpful error message. Not sure how to debug it. by Socrates440

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.