mellery has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I'm currently using Devel:SymDump to get a list of packages for the current execution context. The only problem with this is that it gives me the packages in some sort of internal order (the order they are encountered in a traversal of the global symbols table, I believe). I really need packages in source (declaration) order. Does anyone know if there is a way to obtain packages in source order, short of just grepping through the source file itself?

Replies are listed 'Best First'.
Re: List packages in a file
by Khen1950fx (Canon) on Feb 08, 2010 at 23:56 UTC
Re: List packages in a file
by Anonymous Monk on Feb 08, 2010 at 21:49 UTC
    Hashes (and by extension symbol table) have no order
      yes - I'm aware of this. That's why I'm looking for another way to get the same information without using the symbol table - maybe something like a parse tree of the current source or something like that. I can just grep through the source file myself (looking for package declarations), but I'd rather not do that if there is already a standard package that provides the information I need. Thanks.
        PPI would be a better way of "grepping through the source file".