Rob Dixon wrote: >You need to declare the list of hashes and arrays /before/ and >/outside/ any subroutine that needs them. Like this: > >my (%author_indexlines, %author_headlines, ... ); > >sub read_index { >: >} > >sub read_poem { >: >} >
That's the way I had done it before. But I thought I'd fiddle around with returning references to the hashes and arrays from read_index to write_index (for learning purposes, not for efficieny). >Also, think carefully about whether you need so much common data. I >would expect to see the sort of thing you're using contained within >a single hash. Without knowing more about what you're doing I can't >help any further. I am not sure if I could store all this in one hash: %author_indexlines contains the author's name as a key and a line with author name and a link as its value % author_headlines contains the same keys and the author's name with an anchor for the respective link in %author_indexlines as its value %gedicht_lines contains the same keys and an array of poems for the respective author @author_letters and @gedicht_letters contain the letters for the navigation bar on top of the index page. I did (A..Z) in an earlier version of the script, but then I'd have a Q entry everywhere even if there was no poem title or author beginning with Q. @alphabet_index contains the content of all the arrays from the %gedicht_lines hash. In this case, I could really put it into the &write_index subroutine since it's used nowhere else. But I have no idea how to merge the other variables without loosing track of how to access which part. Please have a look at the index files produced at <http://jan-eden.de/public/literatur/maerchen/index.html> <http://jan-eden.de/public/literatur/maerchen/index2.html> if you are interested. I'd be happy to improve the script further. The closure did a great job, and I noticed that everything I needed to know is right here in both Programming Perl and the Perl Cookbook. Sometimes I find it, sometimes I need this list. Thanks again to Rob and Japhy, Jan > >HTH, > >Rob > > > -- How many Microsoft engineers does it take to screw in a lightbulb? None. They just redefine "dark" as the new standard. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>