Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
go ahead... be a heretic
 
PerlMonks  

Re: Newby question

by Athanasius (Vicar)
on Aug 05, 2012 at 07:30 UTC ( #985496=note: print w/ replies, xml ) Need Help??


in reply to Newby question

Hello Parmenides,

Since this is a learning exercise, here are a couple of points to add to the excellent advice given by CountZero above:

  • Prefer the use warnings; pragma to the -w command line flag. The latter applies globally, so it may give warnings for modules you use in your code but over which you have no control. The former is lexically scoped, and can be turned on and off as needed. See warnings.

  • Despite the superficial similarities, Perl is not C, so you don’t need to declare your variables at the start of a block. It is better practice to declare lexical variables at the point of first use. For example:
    chomp(my $infile = <STDIN>);

By the way, CountZero’s advice about double-quoting variables is explained in What's wrong with always quoting "$vars"?.

(Also, please have a look at How do I compose an effective node title?.)

HTH,

Athanasius <°(((><contra mundum


Comment on Re: Newby question
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2013-05-24 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (505 votes), past polls