Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: creating references

by BioLion (Curate)
on Aug 21, 2009 at 08:38 UTC ( #790282=note: print w/replies, xml ) Need Help??


in reply to creating references

Using diagnostics for more verbose warnings should make things more clear:

#! usr/bin/perl use strict; use warnings; use diagnostics; 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::hash" used only once: possible typo at test.pl line 11 (#1 +) (W once) Typographical errors often show up as unique variable nam +es. If you had a good reason for having a unique name, then just menti +on it again somehow to suppress the message. The our declaration is provided for this purpose. NOTE: This warning detects symbols that have been used only once s +o $c, @c, %c, *c, &c, sub c{}, c(), and c (the filehandle or format) are con +sidered the same; if a program uses $c only once but also uses any of the +others it will not trigger this warning. Name "main::foo" used only once: possible typo at test.pl line 7 (#1) scalar ref defined

The key part explaing the difference in ouput for your two scripts is :

NOTE: This warning detects symbols that have been used only once so $c, @c, %c, *c, &c, sub c{}, c(), and c (the filehandle or format) are considered the same; if a program uses $c only once but also uses any of the others it will not trigger this warning.

There is also a good discussion of a similar problem in "main::Objects" used only once: possible typo. HTH.

Just a something something...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://790282]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2022-05-18 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (70 votes). Check out past polls.

    Notices?