Wiggins d'Anconia wrote:

This example only matches when *all* of the possibles are supplied,

> which is explicitly what he stated he didn't have.

Thanks,

Sorry, careless reading.  I'd thought he only wanted to extract certain values from a 
full string.  This should be a little more robust:

#!/usr/bin/perl -w

use strict;
use warnings;
my %timeHash;

my $str = $ARGV[0];
if ($str =~ /(\d+d)?(\d+h)?(\d+m)?(\d+\.?\d*s)?/) {
 $timeHash{'Day'} = $1 if $1;
 $timeHash{'Hour'} = $2 if $2;
 $timeHash{'Minute'} = $3 if $3;
 $timeHash{'Seconds'} = $4 if $4;
 my $key;
 foreach $key (sort keys (%timeHash)) {  # sort here works only by
                                                                # alphabetic 
coincidence: 'd' < 'h' < 'm' < 's', but it works
   $timeHash{$key} =~ s/[dmhs]//;
   print "$key = $timeHash{$key}\n";
 }
}

Joseph

OT:  What does "INTJ" stand for?



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to