On Wed, 18 Jul 2001, Arvind Baldeo wrote:
> As can be seen above, both $filename and $myfile are same, but it fails when
> I test using the ($myfile eq $filename) operator in the script.
>
> Any suggestions?
First: you are chomping $filename, but putting a newline in $myfile.
Second: use -w and strict
Below is your script with my changes - this runs for me, and given a file
of the right name, prints the 'correct filename' line.
Rachel
> --------------------------------------------------
#!/usr/bin/perl -w
use strict;
my ( $filename, $mon, $hour, $day, $min, $year, $curseq, $myfile );
> chomp( ($filename) = `ls -rt | tail -1` );
>
> #date
> chomp($mon=`date +%m`);
> chomp($hour=`date +%H`);
> chomp($day=`date +%d`);
> chomp($min=`date +%M`);
> chomp($year=`date +%Y`);
> $curseq=$hour*4;
$myfile= "$year.$mon.$day.$curseq.data";
print "$myfile\n";
# old way, with \n
#$myfile= "$year.$mon.$day.$curseq.data\n";
#print "$myfile";
> if ($myfile eq $filename){
> print "The last file has correct filename : $myfile\n";
> }
> --------------------------------------------
Best wishes,
Rachel Coleman
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]