I run a script which creates a small report for different users of a system we have here at work. The report is a simple text document formated with, of all things, the format function. It uses a TOP to create a header for each of our customers which a user has worked with. For some reason the first and only the first write of the TOP results in a double write. The following code
sub writeList { my %users = @_; foreach my $user (keys %users) { open TIMESHEET, ">/work_reports/ticketlists/ticketlists_$endDate/ticketlist_$user" . "_" . "$endDate.txt" or die "Can't open file: $!"; print TIMESHEET "List of tickets worked on by $user during week ending $endDate", "\n\n"; # Print the header for our data using preset formats. They are offset the way they are due to the # requirement that the closing "." be in the first column of the script. All lines have subsequently # been aligned similarly so as not to confuse anyone regarding the association. I would have # declared them earlier in the script but due to the use of scoped variables the compilation # will fail if I do. my $envs_hash = $tickets{$user}; foreach my $env (sort keys %$envs_hash){ format TIMESHEET_TOP = @<<<<<<<<<<<<<<<<<<<< $env Ticket ID Subject Date hh:mm ------------------------------------------------------------------------------- . write TIMESHEET_TOP; my $ids_hash = $envs_hash->{$env}; foreach my $id (sort keys %$ids_hash) { my $subjects_hash = $ids_hash->{$id}; foreach my $subject (keys %$subjects_hash) { format TIMESHEET = @######### ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>> @>>>>> $id, $subject, $rollupDate{$user}{$env}, $$subjects_hash{$subject} ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $subject . write TIMESHEET; } } print TIMESHEET "\n\n"; } close TIMESHEET; } return; } produces the following <begin output> List of tickets worked on by msnyder during week ending 08-19-2007 customer1 Ticket ID Subject Date hh:mm ------------------------------------------------------------------------------- customer1 Ticket ID Subject Date hh:mm ------------------------------------------------------------------------------- 81106 Ticket Subject 08-13-2007 0:20 <end output> It gets that double header. Again, everything else gets only the one, expected, header. Anyone have any ideas as to why the first one always prints twice? Mathew -- Keep up with me and what I'm up to: http://theillien.blogspot.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/