I'm having a hard time successfully writing to filehandles stores in variables. here's how it goes:
# # open report files for printing my $filepath = "/usr/openv/scripts"; open *NTOUT, ">>$filepath/nt.html" or die "cannot open nt file for +writing: $!\n"; open *UNIXOUT, ">>$filepath/unix.html" or die "cannot open unix file +for writing: $!\n"; open *MAILOUT, ">>$filepath/mail.html" or die "cannot open mail file +for writing: $!\n"; # # some unrelated code ...... # foreach my $class ( sort keys %classHash ) { if ( $classHash{$class} = "NT" ) { $outhandle = *NTOUT; } if ( $classHash{$class} = "UNIX" ) { $outhandle = *UNIXOUT; } if ( $classHash{$class} = "MAIL" ) { $outhandle = *MAILOUT; } foreach my $status ( sort keys %{ $classHash{$class} } ) { if ( $status eq "success" ) { print $outhandle <<SUC; <table border=1 width="100%"> <tr> <td colspan="12" align="left" valign="center" bgcolor="#33cc +33"> <b><font size="+1">$class: Successful Jobs</b></font> </td> </tr> SUC
...the print statement print $outhandle (as well as subsequent others) don't actually print to the filehandle. The problem is not with %classHash; I've checked that it is being populated as I expect. But, if I do this:
@fh = ( *NTOUT,*UNIXOUT, *MAILOUT ); foreach (@fh) { print $_ <<EOC; <html> <head> <title>[Backup report] $humanstart - $humanstop</title> </head> <body bgcolor="#ffffff"> <h2 align="left">Daily Backup Report</h2> <h3 align="left">From $humanstart to $humanstop</h3> EOC }
It does print to each filehandle. What am I doing wrong, here?

In reply to typglobs and filehandles by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.