http://www.perlmonks.org?node_id=1007918


in reply to How can I run an folder full of text files through a perl script?

Just for completeness and fun a simple GUI solution for the Mac using AppleScript:

set theWindowTitle to "PerlMonks" set theSuffix to text returned of (display dialog "Enter a file suffix +:" & return default answer "" with title theWindowTitle) set theFolder to (choose folder with prompt "Enter directory") set thePerlScript to quoted form of (POSIX path of ((choose file with +prompt "Select a script:") as Unicode text)) -- display dialog "Script: " & thePerlScript with title theWindowTitle tell application "Finder" set theFiles to (every file of theFolder whose name extension is t +heSuffix) --as alias list end tell repeat with theFile in theFiles set theFile to quoted form of (POSIX path of (theFile as Unicode t +ext)) display dialog "Found: " & theFile with title theWindowTitle set theResult to do shell script thePerlScript & " " & theFile display dialog "Result: " & theResult with title theWindowTitle -- beep end repeat

Perl script:

#!/usr/bin/perl while (<>) {print}

Files:

Karls-Mac-mini:find karl$ cat foo.txt bar.txt foo bar

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»