Hmm,
Firstly, thanks for the reply, i probably should've read up on subroutine parsing before posting, but i was blind to that apparently as it didn't even occur to me (*sigh* a post wasted on an RTFM question, sorry about that). That said, while it's true i didn't need to use a closure, this was practice. The reason for making the sub anonymous was so that only the get_init_strings subroutine could call it, which is a good intent, although admittedly completely wasted here. If i weren't so intent on using something i've never used before it would probably be closer to this (this code needs you to see where the loop happens since it's basically an orcish manuever):
# Code simplified for brevity (again)
my @files = get_files();
my $strings_file = shift(@ARGV) || "default";
my @init_strings;
foreach my $file (@files) {
my @strings = @init_strings ||
get_init_strings($strings_file, \@init_strings);
push @strings, extra_strings();
# manipulate files here
...
}
sub get_init_strings {
my $file = shift;
my $strings = shift;
open FILE, $file or die "Couldn't open $file: $!\n";
push @$strings, $_ while <FILE>;
close FILE, $file or warn "Couldn't close $file: $!\n";
return @$strings;
}
This isn't tested, just the first thing that came to mind. And it would do what i did without any of the hassle. But it's not as much of a learning experience nor as fun :-)
jynx