A few simple steps:
- At the top of your program, open LOGFILE, ">somefilename.log" or die "Can't write logfile: $!";
- After that, select LOGFILE; to make all of your prints go to LOGFILE instead of STDOUT
- At the bottom of the program, don't forget to close LOGFILE or die "Can't close logfile: $!";
Look up open, select, and close for some more details.
perl -e 'print "I love $^X$\"$]!$/"#$&V"+@( NO CARRIER'