. . . Bot code # open the log file my $LogFileName = "log.text"; open my $LOG, '>', "/path/to/log/file/$LogFileName" or die "Eh? Can't create log: $!"; . . . more bot code here while (my $evt = get_next_event()) { print $LOG "Event type found: ", $evt->{EVT_TYPE}, "\n"; if ($evt->{EVT_TYPE} eq "SHUTDOWN") { print $LOG "Shutting down\n"; last; } elsif ($evt->{EVT_TYPE} eq "LIST_INFORMATION") { print $LOG "Information report:\n"; for my $k (%INFORMATION) { print $LOG " $k = '$INFORMATION{$k}\n"; } next; } elsif ( . . . process event } else { print $LOG "Eh? I didn't understand command $evt->{EVT_TYPE}!\n"; } } close $LOG;