On Tue, 5 Dec 2006 at 16:22 -0800, andy@petdance.com via RT <bug-ack@rt.cpa...:
Show quoted text> <URL:
http://rt.cpan.org/Ticket/Display.html?id=23521 >
>
>
> On Dec 5, 2006, at 2:27 PM, via RT wrote:
>
>> The problem goes away if you move the inlined packages up before the
>> main code, and insert "package main;" after that, or wrap the appended
>> packages in a BEGIN {}. (would that have any unexpected side-
>> effects?)
>> I'll try to make a patch that implements the latter.
>
> Please don't yet. I want to investigate further. I can't get it to
> fail in the first place.
I just tested again with rev 89, and the BEGIN { } hint was a clue
to me, as you can see from the patch below, that my File::Next
was declaring a hash (that is used in its "sub files") that
needs to be initialized before someone calls File::Next::files.
When File::Next::files is "used", the file is read in at compile (BEGIN)
time, and the hash is initialized, but when it is just "included",
and put at the end of the file, the hash is not included before
File::Next::files is called. Since you are having trouble reproducing
the problem, what version of File::Next are you using?
$ perldoc -l File::Next
/usr/local/lib/perl5/site_perl/5.9.4/File/Next.pm
$ grep VERSION /usr/local/lib/perl5/site_perl/5.9.4/File/Next.pm
=head1 VERSION
our $VERSION = '0.30';
$ perl -v
This is perl, v5.9.4 built for i686-linux
....
This just shows what I needed to do to get the ack-standalone.txt
file to run.
--- ack-standalone.txt.as-built Tue Dec 5 21:19:01 2006
+++ ack-standalone.txt Tue Dec 5 21:19:36 2006
@@ -471,12 +471,15 @@
our $name; # name of the current file
our $dir; # dir of the current file
-my %files_defaults = (
+my %files_defaults;
+BEGIN {
+ %files_defaults = (
file_filter => sub{1},
descend_filter => sub {1},
error_handler => sub { CORE::die @_ },
sort_files => undef,
);
+}
sub files {
my $passed_parms = ref $_[0] eq 'HASH' ? {%{+shift}} : {}; # copy parm hash
If I apply the following patch to Makefile.pl, (putting File::Next before the main code)
like the following patch, then get a successful standalone perl script.
Index: Makefile.PL
===================================================================
--- Makefile.PL (revision 89)
+++ Makefile.PL (working copy)
@@ -43,8 +43,8 @@
STANDALONE = ack-standalone.txt
standalone: \$(ACK) \$(APP_ACK_PM) \$(FILE_NEXT_PM)
- grep -v 'use App::Ack' \$(ACK) | grep -v 'use File::Next' > \$(STANDALONE)
- cat \$(FILE_NEXT_PM) \$(APP_ACK_PM) >> \$(STANDALONE)
+ cat \$(FILE_NEXT_PM) \$(APP_ACK_PM) > \$(STANDALONE)
+ grep -v 'use App::Ack' \$(ACK) | grep -v 'use File::Next' >> \$(STANDALONE)
chmod +x \$(STANDALONE)
MAKE_FRAG