Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: How to ignore and retrieve certain values from text file which is to be split into multiple HTML files with tables?by Athanasius (Archbishop) |
on Apr 23, 2016 at 03:40 UTC ( [id://1161290]=note: print w/replies, xml ) | Need Help?? |
Hello perly_white, and welcome to the Monastery! The requirements are not entirely clear. If filenames can appear out-of-order in the input file:
then you will need to either (1) read the whole file into a suitable data structure before writing tables, or (2) keep track of each open file, associating the filename with the handle. For (1), you could use a hash of arrays1 like this:
For (2), you would need a simple hash with filename/filehandle key/value pairs. However, it appears from the question that you know in advance that filenames cannot appear out-of-order. If that’s the case, the following skeleton script should provide a straightforward approach:
Update: 1See perldsc#HASHES-OF-ARRAYS. Hope that helps,
In Section
Seekers of Perl Wisdom
|
|