I tried as below with the code you gave, but it dint worked can you please let me know where am doing a mistake.
#!/usr/bin/perl
use strict;
my $dt=`date +%Y-%m-%d`;
chomp $dt;
my $inp_file=""/home/skMessages.log";
{
chomp $inp_file;
open (INFILE,"$inp_file") || die "Cant open $inp_file for reading ";
while \(<INFILE>\)
\{
if \($_ =~ $dt\)
\{
$_="\\n" . $_;$\\="\\n";
print;
\}
\}
}
close(INFILE);
---------- Post updated at 11:55 AM ---------- Previous update was at 11:53 AM ----------
#!/usr/bin/perl
use strict;
my $dt=`date +%Y-%m-%d`;
chomp $dt;
my $inp_file=""/home/skMessages.log";
{
chomp $inp_file;
open (INFILE,"$inp_file") || die "Cant open $inp_file for reading ";
while (<INFILE>)
{
if ($_ =~ $dt)
{
$_="\n" . $_;$\="\n";
print;
}
}
}
close(INFILE);
#!/usr/bin/perl
use strict;
my $dt=`date +%Y-%m-%d`;
chomp $dt;
my $inp_file="/home/skMessages.log";
open (INFILE,"$inp_file") || die "Cant open $inp_file for reading ";
while (chomp ($_=<INFILE>)){
if ($_ =~ $dt){
$_="\n" . $_;
$\="\n";
}
print;
}
close(INFILE);