# writing $line to the appropriate file for $callid. # Filename is assumed to be "log.$callid" and is opened if not open if (not exists $filehandle{$callid}) { open(my $fh,'>','log.'.$callid) or die $!; $filehandle{$callid}= $fh; } my $fh= $filehandle{$callid}; print $fh $line;