22923Re: Time string parsing
- Mar 1, 2006On Tuesday 28 February 2006 10:49, Shawn Hirn wrote:
> I am working with the Time::Interval CPAN module's getIntervalfeature and
[ . . ]
> What I want is a variable called $y that's just the total seconds that'scookbook and
> represented by $x.
> For example, if ...
> $x = 1 hours, 2 minutes, 30 seconds" I want
> $y = 3750
> So, how can I get to $y from $x? I have been reading the Perl
if you want to use the same module in order to get your desired $y result:
$number_of_seconds = convertInterval(
hours => 1,
minutes => 2,
seconds => 30,
ConvertTo => "seconds"
yes, at that above url, its doc says that convertinterval will do that.
Now, whether or not scalar variable can be used instead of the explicit
(example: the explicit 2 for minutes), I don't know. Also you will
parse $x in order to get each of the 3 numbers.
Maybe there's another way, easier. But if scalar variable can be
used, as I
mentioned, then it could be done in this way.
- << Previous post in topic Next post in topic >>