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

Re: [MacPerl] inline edits on files in a user specified folder --how to?



bdr@clark.net writes:
(Another clark.net user!)

}Could you assist me with a vexing MacPERL problem?
}
}I am trying to open a folder and perform a series of inline edits on
}each file inside.
}
} I can get the opertion to work as a droplet but not as a  batch
}process.
}
}
}I have commented or removed some statements as I was working on this
} (| die " .. etc) to simplify what I was looking at
}thanks in advance
}
}Brian Runk
}
}>
}> #!/usr/local/bin/perl5 -w
}> #$^I = ".orig";
}>
}> #choose directory
}> require "GUSI.ph" ;
}> $dir = &MacPerl'Choose(
}>      &GUSI'AF_FILE, 0, "", "",
}>      &GUSI'CHOOSE_DIR);
}> print "$dir\n";
}>
}>
}> #read filenames into an array
}>
}>     opendir(FOLDER,"$dir");

You don't need the above; it's superfluous.

}>     chdir( $dir );
}>     opendir( FOLDER, ':' );
}>     @files = readdir(FOLDER);
}>
}> for (@files)
}>         {
}>         while(<>)

According to the Camel, the magic of <> works only on @ARGV.  Try this:

@ARGV = readdir(FOLDER);
closedir(FOLDER);

while(<>) { #no need for the for loop now
}>           {
}>            s/TEXT STRING/REPLACMENT STRING/g;
}>            print;
}>            }
}>          }
}>
}> closedir(FOLDER);
}>
}> __END__
}>
}>
}

---
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@pjstoaster.pg.md.us



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