Skip to main content


Showing posts with the label Perl

Simplest way to create a log file with Date and Time using PERL

Hi, today em gonna show the simplest way to create log files and add date and time to it so that we can know which event occurred at what point of time. So lets begin. Fetching and Storing Date and Time : use POSIX qw(strftime); my $now = strftime(‘%d-%m-%Y %H:%M:%S’,localtime); Creating Log File : open ($Log,”+>>”,”/home/amar/MyApplication.log”); Printing contents to Log File : print $Log (“$now ******[START OF SCRIPT : DATABASE CHECK]*******\n”); Full Script : This is the simplest way to create a Logger file in Perl. Hope you all enjoyed the post. Do like and Share for more.