Commit da96b30e authored by Dave Morriss's avatar Dave Morriss

Minor tweaks to parse_8601_duration

parent 1051ccaa
......@@ -23,7 +23,7 @@
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
# VERSION: 1.0
# CREATED: 04/07/2013 17:20:09
# REVISION: 05/07/2013 15:55:25
# REVISION: 06/07/2013 10:41:27
#
#===============================================================================
......@@ -33,7 +33,7 @@ use warnings;
my $duration;
my @labels = (qw{Years Months Days Hours Minutes Seconds});
my @labels = qw{Years Months Days Hours Minutes Seconds};
my @fields;
my %iso_duration;
......@@ -68,15 +68,18 @@ my $re = qr{(?x) # Enable embedded whitespace and comments
while ( $duration = shift ) {
print "$duration\n";
#
# Perform the comparison
#
if ( @fields = ( $duration =~ $re ) ) {
#
# Force all undefined fields to be zero
#
@fields = map { ( defined($_) ? $_ : 0 ) } @fields;
#
# Build a duration hash (just to show how to do it in a cool Perly way)
#
#
# Build a duration hash (just to show how to do it in a cool Perly way)
#
@iso_duration{@labels} = @fields;
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment