Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: I am geting an unhelpful error message. Not sure how to debug it.

by GrandFather (Cardinal)
on Jun 18, 2012 at 00:22 UTC ( #976698=note: print w/ replies, xml ) Need Help??


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

When learning is a good time to get into good habits. A few things have been pointed out by previous posters, but lets look at your whole sample and see where it can be improved.

First, using strictures is highly recommended - well done. But it is more conventional now to use use warnings; instead of -w on the command line to enable warnings.

Don't "pre-declare" variables. Declare them where you first need them and generally initialise them at the same time. Get into the habit of using sensible variable names. Short names are ok where they are only used in a small scope, but even then meaningful names can help a lot in understanding code. In particular avoid $a and $b because they have special meaning in the context of sort.

Rolling these suggestions into those from previous replies and applying the scalar fix suggested elsewhere your sample code turns into something like:

#!/usr/bin/perl -w use strict ; my ($a, @line) ; print "Please specify a file." ; chomp ($a = <STDIN>) ; open ($a) ; foreach @line ($a) { print reverse(@line); }

Prints (given the script file as input):

Please specify a file: noname.pl lrep/nib/rsu/!# ;tcirts esu ;sgninraw esu ;" :elif a yficeps esaelP" tnirp ;)>NIDTS< = emanelif$ ym(pmohc ;"n\!$ :emanelif$ nepo t'naC" eid ro emanelif$ ,'<' ,nIelif$ ym nepo { )>nIelif$< = enil$ ym( elihw ;)enil$(esrever ralacs tnirp }
True laziness is hard work


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2014-10-25 09:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (142 votes), past polls