Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
No such thing as a small change

Re: Warnings for unused subs

by danger (Priest)
on Jul 25, 2002 at 16:52 UTC ( #185249=note: print w/ replies, xml ) Need Help??

in reply to Warnings for unused subs

Just an additional note --- 'used only once' won't come into play in a variety of situations:

#!/usr/bin/perl -w use strict; use vars qw/$abc @def %ghi/; our($jkl, @mno, %pqr); my($stu, @vwx, %y_and_z); sub qux {} open(FOO,$0) or die $!; opendir(DIR, '.') or die $!;

In 5.6.1, the above throws warnings for FOO and DIR, and all of the our variables, but nothing else --- in 5.8.0, only FOO and DIR elicit warnings. Variables declared with 'use vars' (and now our) are exempt, as are subroutines and lexicals.

To top it off, 'used only once' really only applies to things in the symbol table, and in particular, is elicited only when the *typeglob is used but once --- as soon as two or more slots in a typeglob are filled, all identifiers within that typeglob are exempt:

#!/usr/bin/perl -w use strict; use vars '$foo'; our(@foo); # second use of *foo $main::bar = 42; %main::bar = (a => 1); # second use of *bar our($FOO, @DIR); open(FOO,$0) or die $!; # second use of *FOO opendir(DIR, '.') or die $!; # second use of *DIR sub blah {} our($blah); # second use of *blah

No warnings --- even though $main::bar is used only once, the *bar identifier is used more than once.

Comment on Re: Warnings for unused subs
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-04-24 10:13 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (565 votes), past polls