Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://185249]
[shmem]: Discipulus reminds me of an irish saying: "I would guess a tomorrow can wait 'til this day is done" :-)
[LanX]: nite! :)
[Discipulus]: or a spanish one: ' qui mucho se despide no quiere despedirse'
shmem slides into the envelope
[shmem]: Discipulus *quien*
[Discipulus]: quien ..
[Discipulus]: me too, i need a Dumas time, see you
[shmem]: que descanses bien, aprendiz
shmem wuff & wech

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-04-29 22:53 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (534 votes). Check out past polls.