# Get filename components ($filename, $filedir, $filext) = fileparse($0, '\..*'); # Create filename; note the ./log sub-dir $logfile = "${filedir}log/$filename.log"; # Redirect STDOUT & STDERR to named logfile open( STDOUT, ">>$logfile") or die "\nUnable to open STDOUT -> $logfile: $!\n"; open( STDERR, ">>&STDOUT"); # Set autoflush on select (STDERR); $| = 1; select (STDOUT); $| = 1;