Created
July 12, 2017 12:25
-
-
Save axtstar/6356a6867858b238667cc36f1997bb87 to your computer and use it in GitHub Desktop.
exchange time(00:00 expression) to number(minutes)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
my $timeStr = ""; | |
my $length = @ARGV; | |
if ($length>0){ | |
$timeStr = $ARGV[0]; | |
} | |
else { | |
$timeStr = <STDIN>; | |
} | |
if ($timeStr =~ /([0-9]+):([0-9]+):([0-9]+)/){ | |
my $var ="$1" * 60 * 60 + "$2" * 60 + "$3"; | |
print "$var"; | |
} elsif ($timeStr =~ /([0-9]+):([0-9]+)/){ | |
my $var ="$1" * 60 + "$2"; | |
print "$var"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ex:
you get the number 22090