learingperl01
MIS
Hello,
I am having trouble getting the following to work. Here is what I am doing,
I have a sub that searches for logs files in a directory that always start and end with 08 and 00.
I then open each one of the files and look try to match another string using regex.
Once the second string is matched I save that string to a variable, split it on : and save the 2 part to an array.
Now using the contents in the second array (@spt1) I want to search for those files names in another directory. The problem is that the $spls variable when printed in the sub wanted does not print anything.
So my question is how do I use the contents of foreach $spls in the "sub wanted" subroutine?
Thanks for the help in advance! sample code.
I am having trouble getting the following to work. Here is what I am doing,
I have a sub that searches for logs files in a directory that always start and end with 08 and 00.
I then open each one of the files and look try to match another string using regex.
Once the second string is matched I save that string to a variable, split it on : and save the 2 part to an array.
Now using the contents in the second array (@spt1) I want to search for those files names in another directory. The problem is that the $spls variable when printed in the sub wanted does not print anything.
So my question is how do I use the contents of foreach $spls in the "sub wanted" subroutine?
Thanks for the help in advance! sample code.
Code:
sub search {
if ( (-f) && /08\..*00$/ )
open the file
while ( $line = <open log file> ) {
if ( $line =~ m/regex/ ) {
@spt = split(/\:/, $line);
push(@spt1,@spt[1]);
foreach $spls (@spt1) {
find(&wanted, $seek_path, $spls);
sub wanted {
print $spls;
}
}
}