Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Using wildcards to open files.

by kcott (Chancellor)
on Oct 26, 2012 at 00:35 UTC ( #1000977=note: print w/replies, xml ) Need Help??


in reply to Re^4: Using wildcards to open files.
in thread Using wildcards to open files.

Where's your code? Where's your input? Where's your output? A vague statement that it didn't work correctly is entirely inadequate. Please read How do I post a question effectively?.

Both methods provided by kennethk work just fine!

$ mv a.msg 'XYZ @ % a.msg' $ cat 'XYZ @ % a.msg' Message A $ cat script.pl print while (<>) $ perl -e ' use strict; use warnings; my @files = glob("*.msg"); for my $file (@files) { print "Filename: $file\n"; my $cmd = "perl script.pl < \Q$file\E"; system($cmd); } ' Filename: b.msg Message B Filename: c.msg Message C Filename: XYZ @ % a.msg Message A $ perl -e ' use strict; use warnings; my @files = glob("*.msg"); for my $file (@files) { print "Filename: $file\n"; my $escaped = quotemeta $file; my $cmd = "perl script.pl < $escaped"; system($cmd); } ' Filename: b.msg Message B Filename: c.msg Message C Filename: XYZ @ % a.msg Message A

Also, my original suggestion of using one process instead of thousands still works without modification:

$ ls -l *.msg -rw-r--r-- 1 ken staff 10 26 Oct 03:01 XYZ @ % a.msg -rw-r--r-- 1 ken staff 10 26 Oct 03:01 b.msg -rw-r--r-- 1 ken staff 10 26 Oct 03:02 c.msg $ perl script.pl *.msg Message A Message B Message C

-- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000977]
help
Chatterbox?
[Corion]: Meh. I need to find myself a better "programming" feed than r/programming (which is just HackerNews reposts and advertisements, very little code). Maybe I should select a list of links that I liked on r/programming and then google for ...
[Corion]: ... an aggregator site that also listed (ideally) all of these links once. And maybe also have an exclude list to blacklist some of the most spammy links that the site may have never mentioned at all

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2017-07-24 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (354 votes). Check out past polls.