technoman007
IS-IT--Management
so here im jst tryin to push all lines with todays date into the array.
but all the data is going thru and getting saved in the array.
$var has this thing
adminode Sun Mar 11 01:53:16 EST 2012 - technoman - sleeping nodename
adminnode Sun Mar 11 01:53:37 EST 2012 - superman - awake nodename
adminnode Sun Jul 19 01:53:37 EST 2012 - superman - awake nodename
so logicaly only the last line should go thru (cos im comparing awk '{print $3}' in date command to awk print $4 in the three lines above).. but all the three lines are goin thru
open(fho,"/home/technoman3/$node.txt");
foreach(<fho>)
{
$var=$_;
#chomp($var);
$i=`date | awk '{print $3}'`;
$p=`echo '$var' | awk '{print $4}'`;
if($p==$i)
{
push(@y,"$var");
}
#push(@y,"$var") if $p == $i;
}
}
$p=0;
foreach(@y)
{
print $_ ;
}
but all the data is going thru and getting saved in the array.
$var has this thing
adminode Sun Mar 11 01:53:16 EST 2012 - technoman - sleeping nodename
adminnode Sun Mar 11 01:53:37 EST 2012 - superman - awake nodename
adminnode Sun Jul 19 01:53:37 EST 2012 - superman - awake nodename
so logicaly only the last line should go thru (cos im comparing awk '{print $3}' in date command to awk print $4 in the three lines above).. but all the three lines are goin thru
open(fho,"/home/technoman3/$node.txt");
foreach(<fho>)
{
$var=$_;
#chomp($var);
$i=`date | awk '{print $3}'`;
$p=`echo '$var' | awk '{print $4}'`;
if($p==$i)
{
push(@y,"$var");
}
#push(@y,"$var") if $p == $i;
}
}
$p=0;
foreach(@y)
{
print $_ ;
}