Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Extract information from several files in directory

by hippo (Bishop)
on Nov 27, 2020 at 15:38 UTC ( [id://11124291]=note: print w/replies, xml ) Need Help??


in reply to Extract information from several files in directory

I have previously managed to do this with one file

That's a good place to start. Might I suggest the following approach to help extend this to several files?

  1. Take your working code and move it into a subroutine (see perlsub) which takes the filename to be read as the only argument. Confirm the script still works as before.
  2. Now simply call the subroutine twice in the script with a different filename each time. Confirm that the script produces the output you expect for two input files.
  3. Now write your loop to find all the files in the directory and just call the subroutine from within the loop. You should now have output from all the files.

Portioning up the code into smaller blocks (such as using subroutines) helps you to work on small parts of a larger problem in isolation. If you have specific problems with any particular part feel free to ask. Remember that an SSCCE is best. Good luck.


🦛

  • Comment on Re: Extract information from several files in directory

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-19 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found