Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2018-03-23 15:02 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (294 votes). Check out past polls.