AquaTeenFryMan
MIS
Hello,
I know this is probably a dumb question to all of you, but I am horrible at programming and need someone to help me with this. How do I get this bit of code (below) into a subroutine so that I can repeat this through out my script. Thank you so much in advance.
my $log_file = pop @logs;
open (FILE, "$dir$log_file");
while(<FILE>){
chomp;
$sn = (split(/\t/,$_))[1];
$sn =~ s/^\s+//;
$sn =~ s/\s+$//;
if ($sn =~ /^[0-9]+$/) {
push(@list, $sn);
}
}
close(FILE);
my $log_file2 = pop @logs;
open (FILE2, "$dir$log_file2");
while(<FILE2>){
chomp;
$sn = (split(/\t/,$_))[1];
$sn =~ s/^\s+//;
$sn =~ s/\s+$//;
if ($sn =~ /^[0-9]+$/) {
push(@list, $sn);
}
}
close(FILE2);
/
I know this is probably a dumb question to all of you, but I am horrible at programming and need someone to help me with this. How do I get this bit of code (below) into a subroutine so that I can repeat this through out my script. Thank you so much in advance.
my $log_file = pop @logs;
open (FILE, "$dir$log_file");
while(<FILE>){
chomp;
$sn = (split(/\t/,$_))[1];
$sn =~ s/^\s+//;
$sn =~ s/\s+$//;
if ($sn =~ /^[0-9]+$/) {
push(@list, $sn);
}
}
close(FILE);
my $log_file2 = pop @logs;
open (FILE2, "$dir$log_file2");
while(<FILE2>){
chomp;
$sn = (split(/\t/,$_))[1];
$sn =~ s/^\s+//;
$sn =~ s/\s+$//;
if ($sn =~ /^[0-9]+$/) {
push(@list, $sn);
}
}
close(FILE2);
/