hnd has asked for the wisdom of the Perl Monks concerning the following question:
the output is right in this case as the compiler need not see a scalar to create a reference but it needs to see a hash to create a reference.... so for this i diduse strict; use warnings; my $scalar_ref=*foo{SCALAR}; print "scalar ref defined\n" if defined $scalar_ref; #------------------------# my hash_ref=*foo{HASH}; print "hash ref defined\n" if defined hash_ref; __END__ output scalar ref defined
now the problem is... the compiler sees that we do hv a hash existing then too the statement hash ref defined doesnt crop up..... why is that????use strict; use warnings; my $scalar_ref=*foo{SCALAR}; print "scalar ref defined\n" if defined $scalar_ref; #------------------------# my %hash=(); my hash_ref=*hash{HASH}; print "hash ref defined\n" if defined hash_ref; __END__ output Name "main::foo" used only once: possible typo at ref.pl Name "main::hash" used only once: possible typo at ref.pl scalar defined
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: creating references
by BioLion (Curate) on Aug 21, 2009 at 08:38 UTC | |
|
Re: creating references
by ikegami (Patriarch) on Aug 22, 2009 at 04:05 UTC | |
|
Re: creating references
by AnomalousMonk (Archbishop) on Aug 21, 2009 at 17:13 UTC | |
by hnd (Scribe) on Aug 22, 2009 at 03:40 UTC |