hi,
i have an array that i want to reuse in a loop. i was resetting the array using @this = ''; until i realized that the $this[0] became ''
now, i'm using undef @this; i'm wondering if this is the way folks generally reuse arrays in loops. here's the base of the code. is this the most efficient, best way to do it? thanks!
my @this;
foreach my $file (@files) {
undef @this;
open (IN, "<$file") or die "$!";
while (<IN>) {
m|^\d{4}| && push (@this, $_);
}
close(IN) or die "$!";
&send_output(\@this);
}
i have an array that i want to reuse in a loop. i was resetting the array using @this = ''; until i realized that the $this[0] became ''
now, i'm using undef @this; i'm wondering if this is the way folks generally reuse arrays in loops. here's the base of the code. is this the most efficient, best way to do it? thanks!
Code:
my @this;
foreach my $file (@files) {
undef @this;
open (IN, "<$file") or die "$!";
while (<IN>) {
m|^\d{4}| && push (@this, $_);
}
close(IN) or die "$!";
&send_output(\@this);
}