> -----Original Message-----
> From: David vd Geer Inhuur tbv IPlib
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 04, 2002 9:05 AM
> To: [EMAIL PROTECTED]
> Subject: skip first array entry and exit foreach loop only
>
>
>
> Hi,
>
> I am looking for a nice solution for the following problem :
>
> I have a directory stored in $header. I need to seek each
> directory for a specific
> file, but I have to start in the deepest dir and than go
> upwards.
All that splitting and reversing seems complicated. Why not
just a simple loop that snips off the last part of the path
each time around? Something like this:
#!/usr/bin/perl
use strict;
my $path = '/usr/local/bin';
my $file = 'foo';
while ($path) {
print "Checking $path\n";
print("Found $path/$file!\n"), last if -e "$path/$file";
$path =~ s!/[^/]*\z!!;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]