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

Re: [MacPerl] Basic MacPerl Q's for Newbie



On Sat, 30 Jan 1999 02:18:16 +0000, Paul Gutches wrote:
>
>Hi Everyone!
>
>I am for all intents and purposes a Perl newbie... and MacPerl listserv
>newbie (although I'm casually familiar with a few OOP languages). 
>
>My sense is that MacPerl is not identical to Perl in all of it's syntax.
> Is this correct?  For example, I read a post the other day that
>mentioned needing to use Mac "CR" instead of the Unix line end?  I
>probably got that wrong... but it sounds important.  Please clarify this
>for me if you will.  

No, MacPerl is identical to Perl in all of its syntax. There are some
things you can do in Unix Perl that won't work in MacPerl because of the
fudamental differences between the operating systems.

Ignore the man behind the curtain about CR. The point being made there was
about downloading software, not writing your own.

>
>My introduction to and first successful MacPerl script grew out of a
>need to quickly change the file extensions on over 20,000 files I'm
>editing for a website (Applescript was dogging it).  While it worked
>great... I couldn't figure out how to maneuver around the Mac Desktop
>into different directories, so I had to resort to copying the script to
>each directory with a folder I wanted to work on.  The Perl directives
>I've learned about so far were turning up "no such file or directory"
>errors.  Anyway... here is the code I used.  Perhaps someone could show
>me what I'd have to do to access folders on various places on my drive
>without having to move the script.  
>(I have several partitions... if that has a bearing on this question). 
>Thanks for any and all replies!  
>
>#! usr/bin/perl
>
>chdir("jagBoard") || die "nope: $!";
>
>foreach $filename (<*.html>){
>
>$newname = $filename;
>
>$newname =~ s/\./\.s/;
>
>rename($filename,$newname) || die "couldn't rename $filename";

So you've switched into a single folder and changed the names in that
single folder. Globbing (*.html) only works on single directory/folders.

The best way to walk a directory tree in MacPerl is to use File::Find. You
can read about it by starting up Shuck and looking at :MacPerl
:lib:File:Find.pm. In general Perl modules are self documenting, and you
can read the documentation with a "pod viewer" such as Shuck.

>
>}
>
>
>-- 
> 
> Paul S Gutches
> Multimedia 1.0
> mailto:webmaster@multimedia1.com
> http://www.multimedia1.com
> 
> "Where The GAMES Are!">
>



-------
Paul J. Schinder
schinder@pobox.com


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