Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Searching a whole directory of databases

by pjf (Curate)
on Jun 24, 2002 at 03:01 UTC ( #176674=note: print w/ replies, xml ) Need Help??


in reply to Searching a whole directory of databases

You might find the following skeleton useful. This assumes you're already in the searchdbs folder.

foreach my $file (<*.txt>) { open(FILE,"< $file") or die "Cannot open $file - $!\n"; # Read in from FILE and do stuff with it... }
Of course, There's More Than One Way To Do It. You might find it easier dropping all the filenames in @ARGV and then using Perl's magic diamond operator:
@ARGV = <*.txt>; while (<>) { # Files will now be opened and read automagically, and # each line placed in $_. You can see which file # you're currently reading from by looking at $ARGV. }
Understanding how the above works is left as an exercise for the reader. ;)

All the best,
Paul Fenwick
Perl Training Australia


Comment on Re: Searching a whole directory of databases
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2015-07-07 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls