in reply to Re^3: Subroutine references inside of a hash with arguments.
in thread Subroutine references inside of a hash with arguments.

#!/usr/bin/perl -- my $f = undef; print "$f\n"; use warnings; print "$f\n"; no warnings; print "$f\n"; __END__ Use of uninitialized value in concatenation (.) or string at - line 7.

Replies are listed 'Best First'.
Re^5: Subroutine references inside of a hash with arguments.
by Marshall (Canon) on Jul 25, 2009 at 09:28 UTC
    Great illustration of the point! If warnings are enabled, printing an "undef" value will generate an error when the code runs. Unlike C or C++, Perl has a notion of a "not yet defined" variable and in many ways this works to HUGE advantage, like assigning a new hash key/value combo, you can just do it without needing to check whether the key exists already or not...the key will be created if it doesn't exist.