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

Re: [MacPerl] MacPerl: Attempting read of folder of files



Wags,

WagsWorld <WagsWorld@aol.com> thoughtfully keystroked:
>I am running MacPerl 5.1.9r4 and am attempting to read a number of e-mail
>files of which I want to extract the return path so as to block junk mail.
>Unfortunately most of my work is done daily on NT 4.0 and MKSToolkit 6.1 using
>perl. The script I have I believe would work on it, but I keep getting
>following error:
>
># WagsWorld 2 :Applications:MacPerl  :00 Macperl  :PL001: Unable to open
>aaaa , <STDIN> chunk 1.
>File 'WagsWorld 2 :Applications:MacPerl  :00 Macperl  :PL001'; Line 44
...

I remember reading more about problems with "glob" on Macs, you would probably
find additional comments by searching the MacPerl archive.

I have had very little success using "glob" on a Mac:
the UNIX-based gurus who wrote glob and/or its in-Perl version make some
assumptions about reasonable characters for file names which nearly
every Mac user (and MSNT/MSW95) doesn't give a whit about,
breaking "glob", such as the assumption:
  "No sensible user who expects 'glob' (and thus normal UNIX shell
   programming) to work will ever use the 'space' character in a file name."

I've had much better success using "opendir", "readdir" and "closedir".

(Example, off the cuff, so this might not compile without twiddling):

$mainloc        =       "WagsWorld 2 :Documentation  :JunkMail";
print "Please enter PERL regular expression syntax glob: ";
chop($globin = <STDIN>);
printf "glob used in processing: $globin\n";

opendir( DATADIR, $base_dir_portion ) or
  die "Error opening dir $mainloc: $!";
@selected_file_list = sort ( grep( m{$perlglob}, readdir( DATADIR ) ) );
closedir( DATADIR );

foreach $filein ( @selected_file_list ) {
   # ...
}

The above will work reliably on any OS PERL has been ported to, as long as
the user understands PERL regular expression syntax.  :)



--
Regards, Larry F. Allen-Tonar        (larryat@cts.com) +1 760/746-6464 (voice)
         Principal Software/Firmware Engineer          +1 860/746-0766 (FAX,
         RYLAR                                                   upon request)
         P.O. Box 463072
         Escondido, CA  92046-3072



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