foreach (sort keys %tickets) { my $ticket = ((split " ",$_)[0]); my %tick_inf; #hash to hold ticket info (%tick_inf = ars_GetEntry($rem,$schema,$ticket)) || warn "Could not retrieve $ticket: $ars_errstr"; #populate the hash with the ticket info my $field_data=$ticket; foreach (@$afield_names){ #these are the fields that we have been asked to grab. $field_data .= " " . $sep; #join the previous data with the seperator unless (exists $hfield_names->{$_}) { print "Bad field name -- $_\n"; next; } unless (exists $tick_inf{$hfield_names->{$_}}) { print $hfield_names->{$_} . "\n"; print "Bad ticket info identifier -- $_ does not relate to: " . $hfield_names->{$_} . "\n"; next; } unless ( defined($tick_inf{$hfield_names->{$_}})) { $field_data .= " "; next; } if (ref($tick_inf{ $hfield_names->{$_} }) eq "ARRAY") #For array references { my $data; foreach (@{ $tick_inf{ $hfield_names->{$_} } }) #foreach of the values of the array ref { $data .= expand_hash($_); #it's always a hash, so expand it out (sub returns a string) } $field_data .= $data; next; #and hit the next value } if ($d_fields->{$_}) #For dates { $field_data .= format_date( $tick_inf{ $hfield_names->{$_} } ); #format the date (sub routine) next; #and hit the next value } if ($l_fields->{$_}) #if the field is a selection value { $field_data .= $l_fields->{$_}->{ #change number into the name: $tick_inf{ #fill the data from the $list field hash $hfield_names->{$_} # } # }; next; } $field_data .= $tick_inf{ $hfield_names->{$_} }; # #value is in the ticket }#close foreach @$fields #more stuff which gets rid of $field_data }