Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How can I run an folder full of text files through a perl script?

by karlgoethebier (Curate)
on Dec 08, 2012 at 19:28 UTC ( #1007918=note: print w/ replies, xml ) Need Help??


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»


Comment on Re: How can I run an folder full of text files through a perl script?
Select or Download Code
Re^2: How can I run an folder full of text files through a perl script?
by tobyink (Abbot) on Dec 08, 2012 at 20:55 UTC

    I've written a couple of AppleScripts before but had forgotten how appallingly bad that language is. Clearly my subconscious had blotted out those memories as some kind of coping mechanism. But now it's all coming flooding back...

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      It was my first one, honestly! Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007918]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-07-30 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls