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

Re: [MacPerl] invisible characters? (fwd)



 Excellent! Thank you so much, I'll be working on this immediately! The only
question I have is regarding a Perl syntax which I haven't encountered
before, which is the useage of "$#theVariable"... Why '$#'? From what I know
about recursive routines, localizing the variables is required... is that
shorthand for 'local()'?

--Jon S. Jaques
--jjaques@grovehillsys.com

-----Original Message-----
From: Mark Manning/Muniz Eng. <mark@cheers.jsc.nasa.gov>
To: Jon S. Jaques <jjaques@grovehillsys.com>
Date: Thursday, July 31, 1997 11:00 AM
Subject: Re: [MacPerl] invisible characters? (fwd)



According to Jon S. Jaques:
>
> Okey dokey, but what about when the files are *known* to be destined for a
> Unix box? THEN what should they be saved as?
Macintosh of course.  The basic reed is: Whatever computer
you are on - that is what you should always save the file
as.  Thus the "Mac-to-Mac" and "Unix-to_Unix".  Although it
is compartmentalizing, that is how computers are.  A Mac
doesn't care about how a Unix box looks at things - only
its way of looking at things.  The same is true for the
Unix boxes.  Which is why there is such a thing as Fetch or
FTP.  These programs were written so when files (especially
text files) are transferred from one computer to the other
they are transferred correctly.  Just like the PC Exchange
program.  Although now hidden in the background where most
people do not even know it exists, PC Exchange exists
solely to allow the transfer of files from one system type
(ie: Macs) to another (like the IBMs).  In effect, Apple
just found a way to make the transfer transparent to a
user.  So instead of now having to bring up Apple File
Exchange; you can just drag and drop files while PC
Exchange does the actual transfer in the background.  Also,
during the transfer, PC Exchange does modify any text files
it might find.  Just like Fetch or FTP does.  :-)

> The particular problem that *I'm* having with this is primarily due to the
> "hord" of ignoramous HTML writers that my boss insists upon employing. One
> cannot ever tell what they are saving as, or even that they know that the
> Evil SimpleText app is forbidden. (Also, does PageMill and Netscape Gold
> have same said "smartness" about them????)
Ah!  That is easily fixed!  Chris posted a program a while
back (and Matthias did so also) which changes the type and
creator flags.  Since I do all of my work by myself - I've
never really bothered to learn how to do it.  So I can't
give you a simple program to do this.  However, it can't be
more than about twenty lines of code to go through and
modify all of the file's type and creator information since
it only takes about ten to fifteen lines of code to read
the entire directory structure off of a computer.  :-)

> Could a script be written that would recursively go through and force fix
> all files to the proper encoding and creator-type (BBEdit, by default) ?
(I
> also administer *another* Mac group which cannot ever get their files
right.
> This script would be an invaluable tool to any such workgroup.)
*nod*  The script to recursively go through any directory is this:

#!perl
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
    @dirList = ();
    @relFiles = ();
    $dirList[++$#dirList] = "<Put your top level directory here>";
    while( $#dirList > -1 ){
        $theDir = $dirList[$#dirList];
        $#dirList--;

        opendir( THEDIR, $theDir );
        @theList = grep( !/^\.\.?$/, readdir(THEDIR) );
        closedir( THEDIR );

        for( $i=0; $i<=$#theList; $i++ ){
            if( -d "$theDir:$theList[$i]" ) {
                $dirList[++$#dirList] = "$theDir:$theList[$i]";
                }
                else {
                    $relFiles[++$#relFiles] = "$theDir:$theList[$i]";
                    }
            }
        }
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#

In the above program you would remove the $relFiles
references and change the ELSE statement on the IF
statement to have to commands which modify the type and
creator information.  Don't forget to use the full pathname
of the file (ie: $theDir:$theList[$i]).  Otherwise you
might get strange and wonderful things happening on your
computer.  :-)




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