Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2020-01-21 22:36 GMT
Find Nodes?
    Voting Booth?