http://qs321.pair.com?node_id=185249


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.