in reply to grepping out global vars?

Maybe the simple solution is to make a copy the script and in the copy.

  1. Comment out or delete any "use vars ..." lines.
  2. edit out any "our" keywords.
  3. Syntax check with "perl -wc copy.pl"

That ought to produce output somethng like:

P:\test>perl -wc junk.pl Global symbol "$c" requires explicit package name at junk.pl line 8. Global symbol "$rv" requires explicit package name at junk.pl line 9. Global symbol "$c" requires explicit package name at junk.pl line 10. Global symbol "$c" requires explicit package name at junk.pl line 11. Global symbol "$c" requires explicit package name at junk.pl line 12. Global symbol "$c" requires explicit package name at junk.pl line 12. Global symbol "$c" requires explicit package name at junk.pl line 17. Global symbol "$rv" requires explicit package name at junk.pl line 22. Global symbol "$c" requires explicit package name at junk.pl line 22. junk.pl had compilation errors.

Is that the sort of information you are after?

There is also a module Devel::Something (Xref?) that produces a cross reference listing, but cpan appears to n down right now.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

Replies are listed 'Best First'.
Re^2: grepping out global vars?
by Mr. Muskrat (Canon) on Jan 18, 2005 at 02:06 UTC

    It's B::Xref and it's pretty cool.

    X:\perl>perl -MO=Xref c:\perl\lib\strict.pm File c:\perl\lib\strict.pm Subroutine (definitions) Package Internals &HvREHASH s0 &SvREADONLY s0 &SvREFCNT s0 &hash_seed s0 &hv_clear_placeholders s0 &rehash_seed s0 Package PerlIO &get_layers s0 Package Regexp &DESTROY s0 Package UNIVERSAL &VERSION s0 &can s0 &isa s0 Package Win32 &BuildNumber s0 &CopyFile s0 &DomainName s0 &FormatMessage s0 &FsType s0 &GetCwd s0 &GetFullPathName s0 &GetLastError s0 &GetLongPathName s0 &GetNextAvailDrive s0 &GetOSVersion s0 &GetShortPathName s0 &GetTickCount s0 &IsWin95 s0 &IsWinNT s0 &LoginName s0 &NodeName s0 &SetChildShowWindow s0 &SetCwd s0 &SetLastError s0 &Sleep s0 &Spawn s0 Subroutine (main) Package (lexical) $default_bits i25 %bitmask i5 Package strict $VERSION 3 &bits &25 c:\perl\lib\strict.pm syntax OK
      It's B::Xref and it's pretty cool.

      There is also a Devel::Xref which I eventually pursuaded CPAN to allow me to download.

      However, the documentation is less than clear (to me) on how to use it. I can get some output, but you have to embed it in the script, and the output is somewhat confusing.

      Now you've pointed out B::Xref, and demonstrated how easy it is to use, I am way impressed. It is really cool. And fast!

      I just tried it out on Date::Manip. Very interesting, if slightly scary reading.

      Thanks for posting, I can see me using that a lot.


      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.
Re^2: grepping out global vars?
by jdporter (Paladin) on Jan 17, 2005 at 16:26 UTC
    That is exactly what I've done, in the past. In fact, since such code is usually (in my experience) written without strict and without use vars (let alone our), simply turning on strict gives you the full scoop on global vars.