[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Fileloop et al.



Chris Nandor wrote:

> At 04.24 10/28/97, Philippe de Rochambeau wrote:
> >What is the equivalent in Perl of Frontier's fileloop command (this
> >command loops through all the files in a particular folder)?
>
> #!perl -wl
> opendir(D,'path:to:dir:') || die $!;
> @dir = readdir(D);
> closedir(D);
> foreach (sort @dir) {print}
>
> >What is the easiest way to access a file's name and modify it (e.g.,
> >shorten its name to 8 characters + 3 char. extension)?
>
> rename $oldfilename, $newfilename;
>
> I'm not sure what you mean by "access a file's name."  You can
> hardcode a filename into the program, or have it entered as input
> somehow (through a droplet or Mac::StandardFile (also will be covered
> in the upcoming chapters)), or get it through readdir().
>
> Perl has a couple globbing functions, but those are implemented via
> the shell, so they are uinimplemented in MacPerl.  So we use
> (open}read|close)dir() instead.
>
> --
> Chris Nandor               pudge@pobox.com           http://pudge.net/
>
> %PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
>
> #==                    MacPerl: Power and Ease                     ==#
>
> #==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#

 By "access a file's name" I mean store an external file's name into a
scalar or store the current script's name into a scalar, modify that
scalar's contents, and change the file's name to its new value.

For instance, if the current script's name ends in "fr" (which stands
for the French version of the script), then open the French data file.
Otherwise, open the US data file.

Philippe de Rochambeau


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch