perl - equal in if statement not working as expected -


use text::diff; $count; our $stats2 = 0; for($count = 0; $count <= 1000; $count++){     $data_dir="archive/oswiostat/oracleapps.*dat";     $data_file= `ls -t $data_dir | head -1`;     chomp($data_file);     while(defined($data_file)){         print $data_file;         open (dat,$data_file) || die("could not open file! $!");         @stats1 = stat $data_file;         @raw_data=<dat>;         close(dat);         print "stats1 :$stats1[9]\n";         sleep(5);         print "checking $stats1[9] equals $stats2\n";         if(chomp($stats1[9]) != chomp($stats2)){             print "i here";             @diff = diff \@raw_data, $data_file, { style => "context" };             print @diff || die ("didn't see updates $!");         }         $stats2 = $stats1[9];         print "stat2: $stats2\n";     } } 

output

[oracle@oracleapps osw]$ perl client_socket1.pl archive/oswiostat/oracleapps.localdomain_iostat_12.06.28.1900.datstats1 :1340925244 checking 1340925244 equals 0 stat2: 1340925244 archive/oswiostat/oracleapps.localdomain_iostat_12.06.28.1900.datstats1 :1340925298 checking 1340925298 equals 1340925244 stat2: 1340925298 archive/oswiostat/oracleapps.localdomain_iostat_12.06.28.1900.datstats1 :1340925304 checking 1340925304 equals 1340925298 stat2: 1340925304 archive/oswiostat/oracleapps.localdomain_iostat_12.06.28.1900.datstats1 :1340925304 checking 1340925304 equals 1340925304 stat2: 1340925304 archive/oswiostat/oracleapps.localdomain_iostat_12.06.28.1900.datstats1 :1340925304 

as show in output when @stats1[9] not equal $stats2 should go if loop , print "i here" not working way. can please identify problem.

chomp() modifies string side-effect , returns linefeed deleted string, not modified string. want write

chomp $stats1[9]; chomp $stats2; if($stats1[9] != $stats2) { 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -