# 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 ; close FILE, $file or warn "Couldn't close $file: $!\n"; return @$strings; }