title: Getting garbage value while calculating difference between already defined and current time (perl script)
body: <p>I have time (only in hours &amp; minutes) defined in one text file and getting current time from machine. Below is my code and am getting garbage value as 3. Code in perl script. Data in text file is as:</p>
  
  <pre><code>                   ##ID::name::time
                     228::one::18 30 30
                     97::two::20 30 00
  </code></pre>
  
  <p>Code is as : Please suggest.</p>
  
  <pre><code>         my $timefromfile;
      open(my $fh, "&lt;", $paramfile) or die("Can't open $paramfile\n") ;
          {
          print "before while\n";
      while (my $line = &lt;$fh&gt;) {
          print "$line\n";
          if($line !~ m/^\#/){
              chomp($line);
          #if line isn't blank, process it
              if($line ne ""){
                  push(@all_linesSettings, $line);
                  my @lineseparator = split(/\::/, $line);
                  $timefromfile = $lineseparator[-1];
                  my $namefromfile = $lineseparator[-2];
                  my $IDfromfile = $lineseparator[-3]; 
                  print "File Time for $IDfromfile $namefromfile is 
                      $timefromfile \n";
  
                  print "**********\n";   
                  (my $sec,my $min,my $hour) = localtime();
                  printf("Current Time is in - HH:MM:SS format  ");
                  #get time into a variable
                  my @t;
                  @t = ($hour, $min, $sec);           
                  print "\n@t\n";
                  print "\n**********\n";
  
                  my $format = '%H %M %S';
                  my $diff = @t - Time::Piece-&gt;strptime($timefromfile, $format );
                  print "\n now slatime is $timefromfile\n";
                  print  "difference in seconds $diff\n";
              }
          }
              }
          }
              close $fh;
              }
  </code></pre>