Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-11-27 19:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (187 votes), past polls