APM: Dumb program acting funny...
Mike Stok
mike at stok.co.uk
Thu Oct 19 03:30:07 PDT 2006
On 19-Oct-06, at 1:14 AM, Bill Raty wrote:
> You have warnings enabled 'the -w switch on shebang'.
>
> With warnings enabled perl will output a message whenever it
> detects an undefined value in a join or string interpolation. To
> demonstrate:
>
> use warnings;
> use strict;
>
> my $empty = undef;
> print "Perl will warn about this $empty string.\n";
>
> I rarely use warnings in production code. It is better to locally
> scope warnings in code sections where you are certain you must
> always have data that is not null.
>
I usually work the other way around, using warnings everywhere, and
then using no warnings as tightly scoped as possible to mark where I
know uninitialized variables and perl's treatment of them are OK
use strict;
use warnings;
my $empty = undef;
{
no warnings 'uninitialized';
print "Perl will not warn about this $empty string.\n";
}
(Let's not notice that $empty is initialized in this code, so the
warning is misleading.)
The same goes for using "no strict 'refs';" around code where I
might be using strings to manipulate the symbol table.
The lexical relaxation reminds me later that I was doing something
"odd" in this chunk of code.
Mike
--
Mike Stok <mike at stok.co.uk>
http://www.stok.ca/~mike/
The "`Stok' disclaimers" apply.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/austin/attachments/20061019/d7802c48/attachment.html
More information about the Austin
mailing list