RE: [Nolug] Perl Question

From: John Souvestre <johns_at_sstar.com>
Date: Fri, 1 Jun 2007 00:39:33 -0500
Message-ID: <001d01c7a40f$3bbe9940$0a01010a@JohnS>

Hi Ray.

Thanks! I did some reading and did find the -f function. But I didn't see
anything about skipping the "do" in the "do while" loop. Can that be done with
other constructs, too?

Thanks,

John

    John Souvestre - Southern Star - (504) 888-3348 - www.sstar.com

-----Original Message-----
From: owner-nolug@redfishnetworks.com [mailto:owner-nolug@redfishnetworks.com]
On Behalf Of -ray
Sent: Friday, June 01, 2007 12:12 AM
To: nolug@nolug.org
Subject: Re: [Nolug] Perl Question

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
___________________
Nolug mailing list
nolug@nolug.org
Received on 06/01/07

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