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

Re: [MacPerl] How I do in a Mac



> Hi
> 
> I am a beginner in Macperl, have a script like this
> 
> #!/usr/local/perl
> while (<>) {
> s/old/new/g;
> print;
> }
> 
> On Unix i write at the prompt
> script oldfile > newfile
> it is easy, but how I do in Macperl
> what I need to change in the script?

Here's what I do:

#!perl -w

foreach $IN (@ARGV) {
  $OUT = "> $IN.out";
  open IN  or die "can't open in: $!";
  open OUT or die "can't open out: $!";
  while (<FILE>) {
    s/old/new/g;
    print OUT;
  }
}
close IN;
close OUT;

__END__

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.

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