XP is just a number | |
PerlMonks |
Re: Question about warnings and arraysby Anonymous Monk |
on Aug 12, 2014 at 23:37 UTC ( [id://1097197]=note: print w/replies, xml ) | Need Help?? |
To begin with, your code:
Now your questions: You should be using warnings, don't comment it out! The warning you're getting is correct - you're trying to read a closed filehandle. You're essentially forcing the loop to end via an error by simply closing the file. Instead you should be using last to exit that loop (that's an alternative to SuicideJunkie's suggested approach above). You mention "an array with delimiters" - that doesn't sound like a good idea, it sounds like what you're looking for is an array of arrays. I suggest you study that page well, along with perlreftut; references are further documented in perlref. Basically, for each file you could declare and populate an array my @pointers (declared inside the foreach), similar to what you're doing with @array now, and then at the end of the foreach you would be adding a reference to that array to @array, with push @array, \@pointers;. If you use that approach, Data::Dumper is very useful visualizing the data structure you've created for understanding what's going on and for debugging: use Data::Dumper; print Dumper(\@array);. Unfortunately your description of "These $pointers will have to be written back to the file at static addresses" is too unclear for me to make good recommendations. You want to take every "pointer"/"line" from your source files and write these to hundreds of other files? Or back to the source files? Do these files already contain data that you are overwriting, or are you generating these files yourself? I think what would really help is some examples of your desired output.
In Section
Seekers of Perl Wisdom
|
|