programming-examples/perl/Datatype/Splitting Time.pl

14 lines
368 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl
use warnings;
use strict;
my ($hours, $minutes, $seconds) = secs2hms(3723);
print "3723 seconds is $hours hours, $minutes minutes and $seconds seconds";
print "\n";
sub secs2hms {
my ($h,$m);
my $seconds = shift;
$h = int($seconds/(60*60)); $seconds %= 60*60;
$m = int($seconds/60); $seconds %= 60;
($h,$m,$seconds);
}