This is a multipart message in MIME format.
--===============1897733010==
Content-Type: multipart/alternative;
boundary="=_alternative 004CF62986257139_="
This is a multipart message in MIME format.
--=_alternative 004CF62986257139_=
Content-Type: text/plain; charset="us-ascii"
Erm, how about...
$hr = $1;
$min = $2;
$sec = $3;
instead? Just a thought.
Ken Barker <kcbarker centurytel.net>
Sent by: activeperl-bounces listserv.ActiveState.com
03/21/2006 08:33 PM
To: "Naresh Bajaj"
<naresh.bajaj gmail.com>,
activeperl listserv.ActiveState.com
cc:
Subject: Re: Extracting numbers from a string
How about using a regex....
if($string =~ /PT(\d+)H(\d+)M(\d+).(\d+)/){
$1=$hr;
$2=$min;
$3=$sec;
$time = ($hr*3600)+($min*60)+$sec;
}
untested....
At 07:28 PM 3/21/2006, Naresh Bajaj wrote:
>Hello all,
>I have one string PT2H46M7.815S.
>It is in hours, minutes and seconds. I want to extract
number between
>the alphabets and
>stored in seconds. How should I approach this problem.
>Right now I am using the split command which is not much
elegant way.
>Crude method:
>extractinterval(PT7.815S)
>sub extractinterval{
> my $interval =$_[0];
> my temp =split //,$interval;
> my $output =
$temp[2].$temp[3].$temp[4].$temp[5];
> }
>Is there any other way of doing.
>Thanks,
>Naresh
>--
>Naresh Bajaj, Intern,
>Cardiac Rhythm Disease Management,
>Medtronic Inc.,
>763-514-3799
>
>_______________________________________________
>ActivePerl mailing list
>ActivePerl listserv.ActiveState.com
>To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
--=_alternative 004CF62986257139_=
Content-Type: text/html; charset="us-ascii"
<br><font size=2
face="sans-serif">Erm, how
about...</font>
<br>
<br><font size=2
face="sans-serif"> $hr =
$1;</font>
<br><font size=2
face="sans-serif"> $min =
$2;</font>
<br><font size=2
face="sans-serif"> $sec =
$3;</font>
<br>
<br><font size=2
face="sans-serif">instead? Just a
thought. </font&g
t;
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1
face="sans-serif"><b>Ken Barker
<kcbarker centurytel.net></b></font>
<br><font size=1
face="sans-serif">Sent by:
activeperl-bounces listserv.ActiveState.com</font>
<p><font size=1
face="sans-serif">03/21/2006 08:33
PM</font>
<br>
<td><font size=1
face="Arial">
</font>
<br><font size=1
face="sans-serif">
To:
"Naresh Bajaj"
<naresh.bajaj gmail.com>, activeperl listserv.ActiveState.com</font>
<br><font size=1
face="sans-serif">
cc:
</font>
<br><font size=1
face="sans-serif">
Subject:
Re: Extracting numbers from a
string</font></table>
<br>
<br>
<br><font size=2 face="Courier
New">How about using a regex....<br>
<br>
if($string =~
/PT(\d+)H(\d+)M(\d+).(\d+)/){<br>
$1=$hr;<br>
$2=$min;<br>
$3=$sec;<br>
$time =
($hr*3600)+($min*60)+$sec;<br>
}<br>
<br>
untested....<br>
<br>
<br>
At 07:28 PM 3/21/2006, Naresh Bajaj wrote:<br>
>Hello all,<br>
>I have one string PT2H46M7.815S.<br>
>It is in hours, minutes and seconds. I want to
extract number between<br>
>the alphabets and<br>
>stored in seconds. How should I approach this
problem.<br>
>Right now I am using the split command which is not
much elegant way.<br>
>Crude method:<br>
>extractinterval(PT7.815S)<br>
>sub extractinterval{<br>
> my
$interval =$_[0];<br>
> my temp
=split //,$interval;<br>
> my
$output = $temp[2].$temp[3].$temp[4].$temp[5];<br>
>
}<br>
>Is there any other way of doing.<br>
>Thanks,<br>
>Naresh<br>
>--<br>
>Naresh Bajaj, Intern,<br>
>Cardiac Rhythm Disease Management,<br>
>Medtronic Inc.,<br>
>763-514-3799<br>
><br>
>_______________________________________________<b
r>
>ActivePerl mailing list<br>
>ActivePerl listserv.ActiveState.com<br>
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs<br>
<br>
_______________________________________________<br>
ActivePerl mailing list<br>
ActivePerl listserv.ActiveState.com<br>
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs<br>
</font>
<br>
<br>
--=_alternative 004CF62986257139_=--
--===============1897733010==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
--===============1897733010==--
|