String to integer

2004-09-09 Thread Eduardo Vazquez Rodriguez
Using regular expressions I match a criteria in a text string, such as: @duration = $string =~ /\sduration=(.*?)\s/; The first element in duration contains 1.23, in a string format When I try to insert $duration[0], into a field of integer type in a database, I get the Following error: Error

RE: String to integer

2004-09-09 Thread Charles K. Clarkson
Eduardo Vazquez Rodriguez [EMAIL PROTECTED] wrote: : How can I convert my string 1.23 into a integer value, : so I can insert correctly in the database The answer is a question. How do you want to convert 1.23 into an integer? use POSIX qw( ceil floor ); print int1.23; # 1 print

Re: String to integer

2004-09-09 Thread Jeff 'japhy' Pinyan
On Sep 9, Eduardo Vazquez Rodriguez said: @duration = $string =~ /\sduration=(.*?)\s/; The first element in duration contains 1.23, in a string format When I try to insert $duration[0], into a field of integer type in a database, I get the Following error: Error Column duration is of type

Re: String to integer

2004-09-09 Thread Eduardo Vazquez Rodriguez
Thats exactly my mistake, thanks to everyone I have a sentence that look like this. $mbd = DBI-connect(dbi:Pg:dbname=$database, $username, $password) or die Error opening database: $DBI::errstr \n; $sth1 = $mbd-prepare ( INSERT INTO public.table