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

[MacPerl] Re:



chipperc.cuntz@mci.com,Internet writes:
>Could anyone provide me with a snipit of MacPerl to process a file dropped
>on a Perl application.  I think I have seen this done here on the list,
>but
>could not find the example.  \
>
Here's a sample of code that I usually use - it processes multiple files.

#!perl -w

foreach $file (@ARGV) {
   unless (-T $file) {next}
   open(FILE, $file) || die "Gak!\n$!\n";
   @lines = <FILE>;
   close(FILE);

   # do whatever processing you want to do...
}
>

exit(0);

As well, you can add some code like...

{
   local $^W = 0;
   require 'StandardFile.pl';
   unless( @ARGV ) {
      $file = StandardFile::GetFile("TEXT");
      $ARGV[0] = ($file) ? $file : undef;
   }
}

above the other code to select a file if no file is dropped. Just note
that using "-w" with StandardFile will net you some warnings unless you
turn off warnings in the block that calls it.

-josh

PS. Feel free to ask more questions if this isn't help enough. Like if you
wanted actual examples of processing, what type of processing would you
like to see?


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