blink has asked for the wisdom of the Perl Monks concerning the following question:
I use filehandles contained in variables elsewhere in the code, only in the successful instance, I don't push them into a hash. It seems that that shouldn't matter; I'm still writing to a filehandle contained in a variable.Can't use string ("*main::INCUNIX") as a symbol ref while "strict refs +" in use at ./nbu-daily-3.pl line 502, <BPDBJOBS> line 2044.
Any thoughts?
An example of %anchors:# for the sake of brevity, I'll include just the relavent code # here's how I open the files to begin with. my @incHandles = (*INCNT, *INCMAIL, *INCUNIX); my $filepath = "/opt/apache/htdocs/nbu/reports"; open $incHandles[0], ">$filepath/inc.nt" or die "cannot open $filep +ath/inc.nt for writing: $!\n"; open $incHandles[1], ">$filepath/inc.mail" or die "cannot open $filep +ath/inc.mail for writing: $!\n"; open $incHandles[2], ">$filepath/inc.unix" or die "cannot open $filep +ath/inc.unix for writing: $!\n"; # then, as I iterate through a couple of hashes, # amongst other things, I call the following two subs ################################################################## sub printTableRow { my ( $outHandle, $status, $class, $incFlag ) = @_; # Hash of colors my %colors = ( active => "#005154", failed => "#ff0000", queued => "#622188", partial => "#ffb90f", success => "#00ff00" ); # Hash of titles my %titles = ( active => "Active Jobs", failed => "Failed Jobs", queued => "Queued Jobs", partial => "Partially Successful Jobs", success => "Successful Jobs" ); $incString = "<a href=\"\#$class\.$titles{$status}\"><font color=\"$co +lors{$status}\">$class</a></font><br>"; my $incHandle; if ( $incFlag eq "N" ) { $incHandle = *INCnt; } if ( $incFlag eq "M" ) { $incHandle = *INCmail; } if ( $incFlag eq "U" ) { $incHandle = *INCunix; } push ( @{$anchors{$incHandle}{$status}}, $incString ); #if ( $incFlag eq "N" ) { print INCnt "$incString\n"; } #if ( $incFlag eq "M" ) { print INCmail "$incString\n"; } #if ( $incFlag eq "U" ) { print INCunix "$incString\n"; } print $outHandle <<ROW; \n<table border=1 width="100%">\n <tr> <td colspan="12" align="left" valign="center" bgcolor="$colors{$sta +tus}" > <b><font size="+2"><a name=\"$class\.$titles{$status}\"</a>$clas +s: $titles{$status}</b></font> </td> </tr> ROW } ################################################################## # print include files for SSI sub printIncludes { my ( $incHandle, $status ); for $incHandle ( keys %anchors ) { for $status ( keys %{ $anchors{$incHandle}} ) { print $incHandle "@{ $anchors{$incHandle}{$status} }\n"; } } } ##################################################################
$VAR3 = '*main::INCUNIX'; $VAR4 = { 'failed' => [ '<a href="#MII-AFS-Filesystem.Failed Jobs"><fo +nt color="#ff0000">MII-AFS-Filesystem</a></font><br>', '<a href="#MII-Media.Failed Jobs"><font color= +"#ff0000">MII-Media</a></font><br>', '<a href="#UNIX-ESMEC.Failed Jobs"><font color +="#ff0000">UNIX-ESMEC</a></font><br>' ], 'success' => [ '<a href="#DB_BACKUP.Successful Jobs"><font c +olor="#00ff00">DB_BACKUP</a></font><br>', '<a href="#HRMS-NT.Successful Jobs"><font col +or="#00ff00">HRMS-NT</a></font><br>', '<a href="#MII-AFS-Filesys-DR.Successful Jobs +"><font color="#00ff00">MII-AFS-Filesys-DR</a></font><br>', '<a href="#MII-Info.Successful Jobs"><font co +lor="#00ff00">MII-Info</a></font><br>', '<a href="#MII-Tuesday.Successful Jobs"><font + color="#00ff00">MII-Tuesday</a></font><br>' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Problems writing to filehandles contained in variables
by merlyn (Sage) on Aug 10, 2002 at 18:01 UTC | |
by tye (Sage) on Aug 11, 2002 at 00:59 UTC | |
|
Re: Problems writing to filehandles contained in variables
by graff (Chancellor) on Aug 11, 2002 at 14:36 UTC |