in reply to Re: no warnings 'uninitialized' (was:Time to seconds)
in thread Time to seconds
It's not weird its perlish.TM ;-)
But seriously, using "uninitialized" variables is done all the time in perl. The weird part is trying to figure out when doing so will trigger a warning and when it won't. I'll be very impressed if you can tell what warnings the following code will produce:
But seriously, using "uninitialized" variables is done all the time in perl. The weird part is trying to figure out when doing so will trigger a warning and when it won't. I'll be very impressed if you can tell what warnings the following code will produce:
#!/usr/bin/perl -T use warnings; use strict; my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m); $a++; $b += 1; $c = $c + 1; $d->{size} = 'big'; $e->[5] = 35; $_ .= "$f"; $_ .= $g; $_ = 'h=' . $h; $_ = $i . '=i'; $_ = "j=$j"; $_ = "$k=k"; $_ = $l x 5; $_ = "$m" x 5;
|
So, how did you do? I contend that you would have scored better on this quiz if I had asked about the values of the expressions rather than about the warnnings they may or may not trigger.
Learning how undef behaves is easy... learning when it tosses warnings is hard. This can lead to gratuitious special-casing (i.e. if ($x && $x > 3) {$y = ($z||0) + 5)) whose sole purpose is to explicitly state that undef should be treated like, well, undef!
-Blake
In Section
Seekers of Perl Wisdom