On 7/5/06, Jeff Peng wrote:
Hello, I think there are not relation between your implement and the filehandle.
As far as I can tell, a format must have the same name as the filehandle to which you want to print it, and once you define a format you cannot change it. So these 2 facts mean you can't have more than 1 format per filehandle. Am I wrong?
To avoid the fact that I have been wrong for understanding your meaning,maybe you would paste some of your codes here.
Here is the code that prints out a bunch of warnings to STDERR and in the output file prints only the second table: #! /usr/bin/env perl use strict; use warnings; my $outfile = "file_with_tables.txt"; open(OUT,">$outfile") or die "Couldn't open $outfile for writing: $!\n"; print OUT "Table 1:\n"; _print_format1(1,15,"foo"); _print_format1(2,8,"bar"); print OUT "\nTable 2:\n"; _print_format2("clk1", 0.04, 12000, 0.51, 0.39, 0.25); _print_format2("clk2", 0.13, 27000, 0.8, 0.5, 0.1); close(OUT) or die "Couldn't close $outfile after writing: $!\n"; sub _print_format1 { # output table 1, with 3 columns my($id,$num_occur,$msg) = @_; format OUT = @<<<<<<<<<<<<<< @>>>>>>>>>>> @<<<<<<<<<<<<<<<<<<<<<<<<< $id, $num_occur, $msg . write OUT; } sub _print_format2 { # output table 2, with 6 columns my($clock,$skew,$num_ffs,$max_lat,$min_lat,$max_tran) = @_; format OUT = @<<<<<<<<<<<< @>>>>>>>>>>>>> @>>>>>>>>> @>>>>>>>>>>>>> @>>>>>>>>>>>>> @>>>>>>>>>>>>>>> $clock, $skew, $num_ffs, $max_lat, $min_lat, $max_tran . write OUT; } # The End! Here a script that illustrates my current workaround: #! /usr/bin/env perl use strict; use warnings; my $outfile = "file_with_tables.txt"; open(OUT,">$outfile") or die "Couldn't open $outfile for writing: $!\n"; print OUT "Table 1:\n"; _print_format1(1,15,"foo"); _print_format1(2,8,"bar"); close(OUT) or die "Couldn't close $outfile after writing: $!\n"; open(NEWOUT,">>$outfile") or die "Couldn't open $outfile for writing: $!\n"; print NEWOUT "\nTable 2:\n"; _print_format2("clk1", 0.04, 12000, 0.51, 0.39, 0.25); _print_format2("clk2", 0.13, 27000, 0.8, 0.5, 0.1); close(NEWOUT) or die "Couldn't close $outfile after writing: $!\n"; sub _print_format1 { # output table 1, with 3 columns my($id,$num_occur,$msg) = @_; format OUT = @<<<<<<<<<<<<<< @>>>>>>>>>>> @<<<<<<<<<<<<<<<<<<<<<<<<< $id, $num_occur, $msg . write OUT; } sub _print_format2 { # output table 2, with 6 columns my($clock,$skew,$num_ffs,$max_lat,$min_lat,$max_tran) = @_; format NEWOUT = @<<<<<<<<<<<< @>>>>>>>>>>>>> @>>>>>>>>> @>>>>>>>>>>>>> @>>>>>>>>>>>>> @>>>>>>>>>>>>>>> $clock, $skew, $num_ffs, $max_lat, $min_lat, $max_tran . write NEWOUT; } # The End! Hope this helps, -- Offer Kaye -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>