fork download
  1. #!/usr/bin/perl
  2. # your code goes here
  3.  
  4. use warnings;
  5. use strict;
  6.  
  7. my $input = "2a";#$ARGV[0];
  8. $|++;
  9.  
  10. my $seconds = 0;
  11. # input could be 1, 1s , 1m or 1h
  12. if ($input =~ /([0-9]+)([smh]?)/i) {
  13. $seconds = $1;
  14. my $unit = lc($2);
  15. my $multiplier = 1;
  16. if ($unit eq "h") {
  17. $multiplier = 3600;
  18. } elsif ($unit eq "m") {
  19. $multiplier = 60;
  20. }
  21. $seconds *= $multiplier;
  22. } else {
  23. die;
  24. }
  25. print $seconds;
  26.  
  27. #while ($seconds) {
  28. # print $seconds;
  29. # sleep 1;
  30. # my $len = length($seconds);
  31. # print "\r", " " x $len, "\r"; $seconds--;
  32. #}
Success #stdin #stdout 0s 6132KB
stdin
Standard input is empty
stdout
2