Now from the looks of that, I think the following would accomplish the same thing, but with only one file open at a time:# open three file handles, for NT page, UNIX page, MAIL page foreach my $class ( sort keys %classHash ) { foreach my $status ( sort keys %{$classHash{$class}} ) { if ( $classname{$class} eq "NT" ) ... # set output to NT page if ( $classname{$class} eq "UNIX" ) ... # set output to UNIX page if ( $classname{$class} eq "MAIL" ) ... # set output to MAIL page ... } }
This way, you only need to be writing one output file at a time (or, as discussed in the earlier post, two files that combine to create a single web page). There's a lot less system overhead this way, and a lot less code to write (which means less code to have to maintain/fix later). I doubt that the three "sort grep {...} keys %hash" calls are going to cause any noticeable delay.foreach my $page (qw/NT UNIX MAIL/) { # open output html file for this page, print the header, # maybe you open a second file for the html to "#include", # then... foreach my $class (sort grep {$classname{$_} eq $page} keys %classHa +sh ) { foreach my $status (sort keys %{$classHash{$class}}) { # print the page content, etc. } } # print the footer and close this output file(s). }
In reply to Re: Problems writing to filehandles contained in variables
by graff
in thread Problems writing to filehandles contained in variables
by blink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |