I knew I should have added it. This is my complete subroutine:<br><br>sub getLogFiles {<br><br><br> my ($logdir,$proc) = @_;<br><br> my @logfilelist =();<br><br> my @files=();<br><br> sub myLogs {<br> /^$proc.*/s<br>
&& push(@files,$File::File::name);<br> }<br><br> find(\&myLogs,$logdir);<br><br> my $filestats={};<br> my $latesttime=0;<br> my $myfile="";<br><br> foreach (@files) {<br><br> $filestats=stat($_);<br>
<br> if ($filestats->mtime>$latesttime) {<br> $myfile=$_;<br> $latesttime=$filestats->mtime;<br> }<br><br> }<br><br><br> push(@logfilelist,$myfile);<br> return @logfilelist;<br><br>}<br><br>My pain is that I want to get the newest file, and the only way I could think of is to add all the files that I want onto a list and compare them. File::Find requires a subroutine, so I made it a nested subroutine, thinking that it would be treated as local..Alas, I learned that Perl doesn' t work like that but still, in theory, this should. But it doesnt . . .<br>
<br><br><div class="gmail_quote">On Wed, Nov 5, 2008 at 6:06 PM, Andy Lester <span dir="ltr"><<a href="mailto:andy@petdance.com">andy@petdance.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
On Nov 5, 2008, at 3:50 PM, Mike Hostetler wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
sub logFinder {<br>
my $proc="pat"<br>
my @files=();<br>
<br>
sub wanted {<br>
/^$proc.*/s<br>
&& push(@files,$File::File::name);<br>
}<br>
<br>
find(\&wanted ,$logdir);<br>
</blockquote>
<br>
<br></div>
First, there's no need to match /^$proc.*/, because it is the same as /^$proc/.<br>
<br>
I think something is missing here. Is wanted() inside of logFinder? Why? Perl doesn't nest subs like that.<br>
<br>
Can you show us an entire program?<br>
<br>
xoa<br>
<br>
<br>
--<br>
Andy Lester => <a href="mailto:andy@petdance.com" target="_blank">andy@petdance.com</a> => <a href="http://www.petdance.com" target="_blank">www.petdance.com</a> => AIM:petdance<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Omaha-pm mailing list<br>
<a href="mailto:Omaha-pm@pm.org" target="_blank">Omaha-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/omaha-pm" target="_blank">http://mail.pm.org/mailman/listinfo/omaha-pm</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Mike Hostetler<br><a href="http://mike.hostetlerhome.com/">http://mike.hostetlerhome.com/</a><br><br><br>