Re: [Nolug] Perl Question

From: -ray <ray_at_ops.selu.edu>
Date: Fri, 1 Jun 2007 00:12:25 -0500 (CDT)
Message-ID: <Pine.LNX.4.61.0706010002450.12345@romulus.csd.selu.edu>

Yep, that's what it's doing. -f is a function that returns true if the
file exists (see man perlfunc). It's just a "do while" loop, that keeps
appending a random digit to the filename until you get a filename that's
not in use.

while ((-f "$filename.tmp") || (-f "$filename.sub")) {
    $filename .= rand(10);
}

ray

On Thu, 31 May 2007, John Souvestre wrote:

> Hi.
>
> I'm trying to figure out a Perl script. One line in it has me baffled.
>
> I believe it is intended to extend a filename till it is unique. But I don't
> quite grasp the syntax.
>
> $filename .= rand(10) while (-f "$filename.tmp") || (-f "$filename.sub");
>
> Is this a shorthand way of writing a "do while" loop?
>
> And what does the "-f" do?
>
> Thanks!
>
> John
>
> John Souvestre - Southern Star - (504) 888-3348 - www.sstar.com
>
>
> ___________________
> Nolug mailing list
> nolug@nolug.org
>

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ray DeJean  				       	 http://www.r-a-y.org
Systems Engineer                    Southeastern Louisiana University
IBM Certified Specialist  	      AIX Administration, AIX Support
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
___________________
Nolug mailing list
nolug@nolug.org
Received on 06/01/07

This archive was generated by hypermail 2.2.0 : 12/19/08 EST