Ken Williams wrote:
On Oct 14, 2005, at 5:37 AM, David Golden wrote:
my $PKG_REGEXP = qr/ # match a package declaration
^[\s\{;]* # intro chars on a line
package # the word 'package'
\s+ # whitespace
([\w:]+) # a package name
\s* # optional whitespace
[;\n] # semicolon or newline termination
/x;
That would mess up on code like the following, though, and your original
would work fine:
__PACKAGE__->mk_accessors(qw(
package filename
line codeline subroutine finished));
our $VERSION = "0.45";
Really the better solution here would be to not parse it line-by-line,
but that's a more major change.
I guess the ideal is PPI, but I don't recommend making that a dependency. ;-)
Oh, well. I suppose semicolon line-starters may need to explicitly declare
a VERSION until/unless we parse the full document. In the documentation
rewrite, we should probably mention that $VERSION should be declared as
early as possible.
David
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
|