in reply to Re: Warning for "unused sub declarations"?
in thread Warning for "unused sub declarations"?

Run this:

#use strict; use warnings; sub bar { print $foo; } my $foo = 1; foo(); bar(); sub foo { print $foo; }
Now uncomment out the use strict; and run it. FWIW, i do the same as you ... but yes, there are consequences.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^3: Warning for "unused sub declarations"?
by thor (Priest) on May 19, 2005 at 23:15 UTC
    Maybe I'm a little slow, but are you and I talking about two different things? As far as I can tell, your bar routine depends on the global variable $foo which doesn't exist when bar is defined. What I was talking about was the need (or lack thereof) to put a superfluous declaration of all user-defined subs at the beginning of the file.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      Actually ... i was wrong. We are talking about 2 different things. I was thinking that by declaring subs "superfluously" you could guard against using global lexicals. I thought that was the reason for declaring subs before hand, other than pseudo-documentation, but turns out i was wrong.

      speaking of thor ... here's something amusing ...

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)