Perl Syntax
Kevin C. Krinke
kckrinke-eqjHHVKjh9GttCpgsWEBFlaTQe2KTcn/ at public.gmane.org
Tue May 24 22:05:12 UTC 2005
On Tue, 2005-05-24 at 16:36 -0400, Andrew Hammond wrote:
<snipped for brevity>
> That is what's happening in this case. IMHO, barewords are evil and
> should not appear in documentation except as examples of the "hackish"
> solution.
IMHO barewords are perfectly fine and in fact feels very natural when I
type them out in my code.
> This also looks like another pretty common trick, the zero parameter
> inline function. This is often used to represent constants. Example follows.
>
> sub INT () { 2 }
Now that, I will agree, is "evil" and "hackish"... use this instead for
constants:
use constant INT => 2;
hehe
> If you're learning perl, the best advice I can give you is to start
> every single one of your programs with "use strict;", which will not
> allow you to use barewords. It can save you from developing some
> particularly bad habits.
In addition to "use strict;" I would also very highly recommend it's
often seen counterpart "use warnings;" and the dreaded "use
diagnostics;". In particular the "use diagnostics;" pragma will give
hints and suggestions as to what's going on, what's potentially gone
wrong and possibly even how to fix it. The elite don't like the
diagnostics but newbies to Perl will definitely benefit from the
experience it provides.
When I first started to learn Perl someone instructed me to use the
following as a starter template for every Perl script I write until I
understood everything that was going on and became confident enough in
my understanding of Perl.
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
--
Kevin C. Krinke <kckrinke-eqjHHVKjh9GttCpgsWEBFlaTQe2KTcn/@public.gmane.org>
Open Door Software Inc.
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list