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

foreach @line ($a) {

Lookup foreach in the documentation. If you use two variables with foreach, the first one must be a scalar, not an array.

By the way: Your code either lacks

or die "Can't open '$a': $!"

after open or use autodie; after use strict;. And unless you have a very strangely named file on your filesystem, it will die. Lookup chomp.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: I am geting an unhelpful error message. Not sure how to debug it.
by Socrates440 (Acolyte) on Jun 15, 2012 at 04:41 UTC
    Can I reverse each line if I store them in scalers? The exersize requires that I reverse each line before I print them. The only mechanism that I have for doing that only works with arrays (or so I believe.)
      Yes "reverse" works with scalars as well.(When maintained in a scalar context)

      It all depends on what you want to end-up with. Reverse on a scalar reverses the letters (Make sure you do this in a SCALAR context). On an array, it reverses the order of the elements.

      One way to achieve reversal would be to take the scalar, 'split' it into an array, and reverse the array.

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

      perl -e "my $str='abcdef'; print scalar (reverse ($str));"