From robert.l.harris at gmail.com Tue Jul 1 11:26:32 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Tue, 1 Jul 2014 12:26:32 -0600 Subject: [Denver-pm] Text::CSV not parsing embedded commas? Message-ID: Given this line: $_= file1,field2,field3,"more text, in this field 4",field5,field6 I would expect the output of ( $va1, $var2, $var3, $var4, $var5, $var6 )=$csv->fields(); to yield: $var1=field1 $var2=field2 $var3=field3 $var4="more text, in this field 4" $var5=field5 $var6=field6 Instead though I get $var1=field1 $var2=field2 $var3=field3 $var4="more text $var5= in this field 4" $var6=field5 What am I missing? Robert -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From geovanny at eutsiv.com Tue Jul 1 12:10:12 2014 From: geovanny at eutsiv.com (Geovanny Junio :: eutsiv) Date: Tue, 1 Jul 2014 16:10:12 -0300 Subject: [Denver-pm] Text::CSV not parsing embedded commas? In-Reply-To: References: Message-ID: Hi Robert! Did you change the quote_char config? my $csv = Text::CSV->new ({ binary => 1, quote_char => '"' }); Cheers, -- Geovanny Junio Consultor de Tecnologia geovanny (at) eutsiv.com +55 31 9422-8885 +55 31 2519-8603 www.eutsiv.com Este e-mail pode conter informa??o privilegiada e confidencial. Se voc? n?o ? destinat?rio da mensagem, por favor apague a mensagem e comunique-nos o fato de imediato. This e-mail contains information that may be privileged and confidential. If you are not the intended recipient, please delete the e-mail and notify us immediately. On Tue, Jul 1, 2014 at 3:26 PM, Robert L. Harris wrote: > > Given this line: > > $_= file1,field2,field3,"more text, in this field 4",field5,field6 > > I would expect the output of ( $va1, $var2, $var3, $var4, $var5, $var6 > )=$csv->fields(); to yield: > > $var1=field1 > $var2=field2 > $var3=field3 > $var4="more text, in this field 4" > $var5=field5 > $var6=field6 > > Instead though I get > > $var1=field1 > $var2=field2 > $var3=field3 > $var4="more text > $var5= in this field 4" > $var6=field5 > > What am I missing? > > Robert > > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > > _______________________________________________ > Denver-pm mailing list > Denver-pm at pm.org > http://mail.pm.org/mailman/listinfo/denver-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From three18ti at gmail.com Tue Jul 1 13:58:38 2014 From: three18ti at gmail.com (Jon) Date: Tue, 1 Jul 2014 14:58:38 -0600 Subject: [Denver-pm] Denver-pm Digest, Vol 12, Issue 1 In-Reply-To: References: Message-ID: Hi Robert, Can you give us a little more of your code? It works as expected for me using both Text::CSV_XS and Text::CSV: >> $ perl -v >> This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux >> $ perl -MText::CSV_XS -MData::Dumper -e '$_ = "file 1,file 2,\"foo, bar\",file 3"; my $csv = Text::CSV_XS->new(); $csv->parse($_); @cols = $csv->fields; print Dumper \@cols;' >> $VAR1 = [ >> 'file 1', >> 'file 2', >> 'foo, bar', >> 'file 3' >> ]; >> $ perl -MText::CSV -MData::Dumper -e '$_ = "file 1,file 2,\"foo, bar\",file 3"; my $csv = Text::CSV_XS->new(); $csv->parse($_); @cols = $csv->fields; print Dumper \@cols;' >> $VAR1 = [ >> 'file 1', >> 'file 2', >> 'foo, bar', >> 'file 3' >> ]; Best Regards, Jon A On Tue, Jul 1, 2014 at 1:00 PM, wrote: > Send Denver-pm mailing list submissions to > denver-pm at pm.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.pm.org/mailman/listinfo/denver-pm > or, via email, send a message with subject or body 'help' to > denver-pm-request at pm.org > > You can reach the person managing the list at > denver-pm-owner at pm.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Denver-pm digest..." > > > Today's Topics: > > 1. Text::CSV not parsing embedded commas? (Robert L. Harris) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 1 Jul 2014 12:26:32 -0600 > From: "Robert L. Harris" > To: Denver-pm at pm.org > Subject: [Denver-pm] Text::CSV not parsing embedded commas? > Message-ID: > H2XU7fRg at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Given this line: > > $_= file1,field2,field3,"more text, in this field 4",field5,field6 > > I would expect the output of ( $va1, $var2, $var3, $var4, $var5, $var6 > )=$csv->fields(); to yield: > > $var1=field1 > $var2=field2 > $var3=field3 > $var4="more text, in this field 4" > $var5=field5 > $var6=field6 > > Instead though I get > > $var1=field1 > $var2=field2 > $var3=field3 > $var4="more text > $var5= in this field 4" > $var6=field5 > > What am I missing? > > Robert > > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.pm.org/pipermail/denver-pm/attachments/20140701/f234ec09/attachment-0001.html > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Denver-pm mailing list > Denver-pm at pm.org > http://mail.pm.org/mailman/listinfo/denver-pm > > > ------------------------------ > > End of Denver-pm Digest, Vol 12, Issue 1 > **************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.l.harris at gmail.com Tue Jul 1 15:22:51 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Tue, 1 Jul 2014 16:22:51 -0600 Subject: [Denver-pm] Better way to handle vars? Message-ID: OK, so I'm parsing a ton of data based on patterns in the lines. Given the line I pull out 3 things, Timestamp Key Value Right now for one of my patters I have $Insert="insert into table ( TIMESTAMP, KEY, VALUE ) values ( $Timestamp, $Key, $Value )"; ( effectively ). I'm going to have about 20+ of these patterns. The actual insert is about 5x longer. Is there a way to "template" the Insert so I can basically reference the template in the pattern and re-use the template? That way if the template has to change down the line ( a new field added ) I update the template and not 20+ variables? Robert -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From saj at thecommune.net Tue Jul 1 15:28:56 2014 From: saj at thecommune.net (Stuart A Johnston) Date: Tue, 01 Jul 2014 16:28:56 -0600 Subject: [Denver-pm] Better way to handle vars? In-Reply-To: References: Message-ID: <53B33628.7060900@thecommune.net> I think we'd need a bit more detail to answer your exact question but you might find this article helpful: http://www.perl.com/pub/2001/03/dbiokay.html On 07/01/2014 04:22 PM, Robert L. Harris wrote: > > OK, so I'm parsing a ton of data based on patterns in the lines. Given > the line I pull out 3 things, > Timestamp > Key > Value > > Right now for one of my patters I have > > $Insert="insert into table ( TIMESTAMP, KEY, VALUE ) values ( > $Timestamp, $Key, $Value )"; > > ( effectively ). > > I'm going to have about 20+ of these patterns. The actual insert is > about 5x longer. Is there a way to "template" the Insert so I can > basically reference the template in the pattern and re-use the template? > That way if the template has to change down the line ( a new field > added ) I update the template and not 20+ variables? > > Robert > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > > > _______________________________________________ > Denver-pm mailing list > Denver-pm at pm.org > http://mail.pm.org/mailman/listinfo/denver-pm > From deandre at deandrecarroll.com Tue Jul 1 15:49:53 2014 From: deandre at deandrecarroll.com (deandre) Date: Tue, 01 Jul 2014 16:49:53 -0600 Subject: [Denver-pm] Better way to handle vars? Message-ID: If I understand your problem correctly, this is the type of work for which prepared statements are created. $ sth = $ dbh-> prepare ("insert into table ( TIMESTAMP, KEY, VALUE ) values ( ?,?,? )"; $ sth-> execute($Timestamp, $Key, $Value); Values passed to execute are escaped, thus preventing possible sales injection. Plus the statement handle goes through a sort of compilation making repeated use (by adding new values to the execute) much faster. Sent on a Sprint Samsung Galaxy S? III
-------- Original message --------
From: "Robert L. Harris"
Date:07/01/2014 4:22 PM (GMT-07:00)
To: Denver-pm at pm.org
Subject: [Denver-pm] Better way to handle vars?
OK, so I'm parsing a ton of data based on patterns in the lines. Given the line I pull out 3 things, Timestamp Key Value Right now for one of my patters I have $Insert="insert into table ( TIMESTAMP, KEY, VALUE ) values ( $Timestamp, $Key, $Value )"; ( effectively ). I'm going to have about 20+ of these patterns. The actual insert is about 5x longer. Is there a way to "template" the Insert so I can basically reference the template in the pattern and re-use the template? That way if the template has to change down the line ( a new field added ) I update the template and not 20+ variables? Robert -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at fedde.us Tue Jul 1 19:06:31 2014 From: chris at fedde.us (Chris Fedde) Date: Tue, 1 Jul 2014 20:06:31 -0600 Subject: [Denver-pm] Better way to handle vars? In-Reply-To: References: Message-ID: SQL is just text so generating it is pretty easy. For insert statements I sometimes craft lines like this: use Modern::Perl; my @fields = qw(TIMESTAMP KEY VALUE); my $insert = "insert into table (" . join(", ", @fields) . ") values (" . join( ", ", ("?")x at fields) . ")"; say $insert There are also LOADS of SQL modules on CPAN. One of my favorite for mucking about with plain old SQL is SQL::Abstract use Modern::Perl; use SQL::Abstract; my $sql = SQL::Abstract->new; my %fields = ( TIMESTAMP => scalar gmtime, KEY => rand(), VALUE => "some value", ); my ($insert, @bind) = $sql->insert('table', \%fields); say $insert. "\n"; say for (@bind); On Tue, Jul 1, 2014 at 4:49 PM, deandre wrote: > If I understand your problem correctly, this is the type of work for which > prepared statements are created. > > > $ sth = $ dbh-> prepare ("insert into table ( TIMESTAMP, KEY, VALUE ) > values ( ?,?,? )"; > > $ sth-> execute($Timestamp, $Key, $Value); > > Values passed to execute are escaped, thus preventing possible sales > injection. Plus the statement handle goes through a sort of compilation > making repeated use (by adding new values to the execute) much faster. > > Sent on a Sprint Samsung Galaxy S? III > > > -------- Original message -------- > From: "Robert L. Harris" > Date:07/01/2014 4:22 PM (GMT-07:00) > To: Denver-pm at pm.org > Subject: [Denver-pm] Better way to handle vars? > > > OK, so I'm parsing a ton of data based on patterns in the lines. Given > the line I pull out 3 things, > Timestamp > Key > Value > > Right now for one of my patters I have > > $Insert="insert into table ( TIMESTAMP, KEY, VALUE ) values ( $Timestamp, > $Key, $Value )"; > > ( effectively ). > > I'm going to have about 20+ of these patterns. The actual insert is about > 5x longer. Is there a way to "template" the Insert so I can basically > reference the template in the pattern and re-use the template? That way if > the template has to change down the line ( a new field added ) I update the > template and not 20+ variables? > > Robert > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > > _______________________________________________ > Denver-pm mailing list > Denver-pm at pm.org > http://mail.pm.org/mailman/listinfo/denver-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.l.harris at gmail.com Wed Jul 2 11:50:13 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Wed, 2 Jul 2014 12:50:13 -0600 Subject: [Denver-pm] Text::CSV not parsing embedded commas? In-Reply-To: References: Message-ID: So I found out WHY the idiot put the ' $_ =~ s/"//;' in the script. I still get to beat him for doing it without telling us, but the 'why' is legitimate. Change the value of $_ to this: $_= file1,field2,field3,"more text, in this field 4,field5,field6 ( Field 4 generaly contains user input which is quoted, but it is truncated. If the user input is > than that fiels will be missing the final closing quotes. ) Now I have no idea how to compensate for that. Robert On Tue, Jul 1, 2014 at 12:26 PM, Robert L. Harris wrote: > > Given this line: > > $_= file1,field2,field3,"more text, in this field 4",field5,field6 > > I would expect the output of ( $va1, $var2, $var3, $var4, $var5, $var6 > )=$csv->fields(); to yield: > > $var1=field1 > $var2=field2 > $var3=field3 > $var4="more text, in this field 4" > $var5=field5 > $var6=field6 > > Instead though I get > > $var1=field1 > $var2=field2 > $var3=field3 > $var4="more text > $var5= in this field 4" > $var6=field5 > > What am I missing? > > Robert > > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at fedde.us Fri Jul 4 09:02:38 2014 From: chris at fedde.us (Chris Fedde) Date: Fri, 4 Jul 2014 10:02:38 -0600 Subject: [Denver-pm] Text::CSV not parsing embedded commas? In-Reply-To: References: Message-ID: #!perl use Modern::Perl; use Text::CSV; $_= q|file1,field2,field3,"more text, in this field 4",field5,field6|; my $csv = Text::CSV->new(); $csv->parse($_); say for $csv->fields; On Wed, Jul 2, 2014 at 12:50 PM, Robert L. Harris wrote: > > So I found out WHY the idiot put the ' $_ =~ s/"//;' in the script. I > still get to beat him for doing it without telling us, but the 'why' is > legitimate. > > Change the value of $_ to this: > > $_= file1,field2,field3,"more text, in this field 4,field5,field6 > > ( Field 4 generaly contains user input which is quoted, but it is > truncated. If the user input is > than that fiels will be missing the > final closing quotes. ) > > Now I have no idea how to compensate for that. > > Robert > > > > > > > > On Tue, Jul 1, 2014 at 12:26 PM, Robert L. Harris < > robert.l.harris at gmail.com> wrote: > >> >> Given this line: >> >> $_= file1,field2,field3,"more text, in this field 4",field5,field6 >> >> I would expect the output of ( $va1, $var2, $var3, $var4, $var5, $var6 >> )=$csv->fields(); to yield: >> >> $var1=field1 >> $var2=field2 >> $var3=field3 >> $var4="more text, in this field 4" >> $var5=field5 >> $var6=field6 >> >> Instead though I get >> >> $var1=field1 >> $var2=field2 >> $var3=field3 >> $var4="more text >> $var5= in this field 4" >> $var6=field5 >> >> What am I missing? >> >> Robert >> >> >> >> -- >> :wq! >> >> --------------------------------------------------------------------------- >> Robert L. Harris >> >> DISCLAIMER: >> These are MY OPINIONS With Dreams To Be A King, >> ALONE. I speak for First One Should Be A Man >> no-one else. - Manowar >> > > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > > _______________________________________________ > Denver-pm mailing list > Denver-pm at pm.org > http://mail.pm.org/mailman/listinfo/denver-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.l.harris at gmail.com Thu Jul 17 13:17:36 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Thu, 17 Jul 2014 14:17:36 -0600 Subject: [Denver-pm] Playing with WWW::Mechanize Message-ID: OK, trying to redo a very old script using WWW:Mechanize. The point of the script is I have a .conf file with 30 comics I like to read daily and can hit this cgi-bin which just walks through the comics. Right now I'm working on a simple loop which gives me the URL's so I can write my own html to display all 30 in one page nice and simple. I'm not doing something right with the text_regex it seems as I'm not getting the URL of the actual comic image. http://pastie.org/9400894 Anyone have any input? Robert -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.l.harris at gmail.com Thu Jul 17 13:23:33 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Thu, 17 Jul 2014 14:23:33 -0600 Subject: [Denver-pm] Playing with WWW::Mechanize In-Reply-To: References: Message-ID: Bah, found an irrelevant typo ( not in the real script ), this paste has it fixed: http://pastie.org/9400909 On Thu, Jul 17, 2014 at 2:17 PM, Robert L. Harris wrote: > > OK, trying to redo a very old script using WWW:Mechanize. The point of > the script is I have a .conf file with 30 comics I like to read daily and > can hit this cgi-bin which just walks through the comics. Right now I'm > working on a simple loop which gives me the URL's so I can write my own > html to display all 30 in one page nice and simple. > > I'm not doing something right with the text_regex it seems as I'm not > getting the URL of the actual comic image. > > http://pastie.org/9400894 > > Anyone have any input? > > Robert > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From three18ti at gmail.com Sun Jul 20 12:13:19 2014 From: three18ti at gmail.com (Jon) Date: Sun, 20 Jul 2014 13:13:19 -0600 Subject: [Denver-pm] Denver-pm Digest, Vol 12, Issue 5 In-Reply-To: References: Message-ID: Bah. Pastie is giving me a 503/ service not available. Past it to the "perl" pastebin? (W''re all familiar with shadow cat / matt s. Trout aka mst right) Feel free to email me directly as I only get digests it will take me a while to reply. (Don't forget to cc the mailing list) Thanks! Jon A On Jul 20, 2014 1:00 PM, wrote: > Send Denver-pm mailing list submissions to > denver-pm at pm.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.pm.org/mailman/listinfo/denver-pm > or, via email, send a message with subject or body 'help' to > denver-pm-request at pm.org > > You can reach the person managing the list at > denver-pm-owner at pm.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Denver-pm digest..." > > > Today's Topics: > > 1. Playing with WWW::Mechanize (Robert L. Harris) > 2. Re: Playing with WWW::Mechanize (Robert L. Harris) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 17 Jul 2014 14:17:36 -0600 > From: "Robert L. Harris" > To: Denver-pm at pm.org > Subject: [Denver-pm] Playing with WWW::Mechanize > Message-ID: > RGijd0x-j2R8sdsdqA at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > OK, trying to redo a very old script using WWW:Mechanize. The point of the > script is I have a .conf file with 30 comics I like to read daily and can > hit this cgi-bin which just walks through the comics. Right now I'm > working on a simple loop which gives me the URL's so I can write my own > html to display all 30 in one page nice and simple. > > I'm not doing something right with the text_regex it seems as I'm not > getting the URL of the actual comic image. > > http://pastie.org/9400894 > > Anyone have any input? > > Robert > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.pm.org/pipermail/denver-pm/attachments/20140717/06b5e9f7/attachment-0001.html > > > > ------------------------------ > > Message: 2 > Date: Thu, 17 Jul 2014 14:23:33 -0600 > From: "Robert L. Harris" > To: Denver-pm at pm.org > Subject: Re: [Denver-pm] Playing with WWW::Mechanize > Message-ID: > NgJyLDiDNZa75wOQ-XoKCrr9M9VLG7Ztt1z9yDHGA at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Bah, found an irrelevant typo ( not in the real script ), this paste has > it fixed: http://pastie.org/9400909 > > > On Thu, Jul 17, 2014 at 2:17 PM, Robert L. Harris < > robert.l.harris at gmail.com > > wrote: > > > > > OK, trying to redo a very old script using WWW:Mechanize. The point of > > the script is I have a .conf file with 30 comics I like to read daily and > > can hit this cgi-bin which just walks through the comics. Right now I'm > > working on a simple loop which gives me the URL's so I can write my own > > html to display all 30 in one page nice and simple. > > > > I'm not doing something right with the text_regex it seems as I'm not > > getting the URL of the actual comic image. > > > > http://pastie.org/9400894 > > > > Anyone have any input? > > > > Robert > > > > > > -- > > :wq! > > > --------------------------------------------------------------------------- > > Robert L. Harris > > > > DISCLAIMER: > > These are MY OPINIONS With Dreams To Be A King, > > ALONE. I speak for First One Should Be A Man > > no-one else. - Manowar > > > > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.pm.org/pipermail/denver-pm/attachments/20140717/4137632d/attachment-0001.html > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Denver-pm mailing list > Denver-pm at pm.org > http://mail.pm.org/mailman/listinfo/denver-pm > > > ------------------------------ > > End of Denver-pm Digest, Vol 12, Issue 5 > **************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.l.harris at gmail.com Wed Jul 23 13:11:56 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Wed, 23 Jul 2014 14:11:56 -0600 Subject: [Denver-pm] Scientific Notation -> Dec????? Message-ID: OK, I'm parsing through a bunch of data. Occasionally I get something like : $State="-7.7800825e-05" Usually the "e" is capital ( I don't know why this product logs it this way ). When the Capital E goes through the if statements below it converts fine, but the lower case does not it seems... I have put in the following sections to convert this: $State =~ tr/e/E/; if ( $State =~ /E/ ) { $State2 = sprintf("%.10g", $State); $State=$State2; } if ( $State =~ /e/ ) { $State2 = sprintf("%.10g", $State); $State=$State2; } Any ideas? -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From larryl at emailplus.org Wed Jul 23 13:36:08 2014 From: larryl at emailplus.org (Larry Leszczynski) Date: Wed, 23 Jul 2014 14:36:08 -0600 Subject: [Denver-pm] Scientific Notation -> Dec????? In-Reply-To: References: Message-ID: <1406147768.27943.144957561.06FC8480@webmail.messagingengine.com> Hi Robert - > OK, I'm parsing through a bunch of data. Occasionally I get something > like > : > $State="-7.7800825e-05" > > Usually the "e" is capital ( I don't know why this product logs it this > way > ). When the Capital E goes through the if statements below it converts > fine, but the lower case does not it seems... > > I have put in the following sections to convert this: > > $State =~ tr/e/E/; > > if ( $State =~ /E/ ) { > $State2 = sprintf("%.10g", $State); > $State=$State2; > } > if ( $State =~ /e/ ) { > $State2 = sprintf("%.10g", $State); > $State=$State2; > } What are you trying to do with these values? If you use them in numeric context, they work fine as-is, no matter if they have a "e" or "E": $ perl -de 0 Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 DB<1> print 0 + "-7.7800825e-05" -7.7800825e-05 DB<2> print 0 + "-7.7800825E-05" -7.7800825e-05 Larry From robert.l.harris at gmail.com Wed Jul 23 17:00:50 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Wed, 23 Jul 2014 18:00:50 -0600 Subject: [Denver-pm] Scientific Notation -> Dec????? In-Reply-To: <1406147768.27943.144957561.06FC8480@webmail.messagingengine.com> References: <1406147768.27943.144957561.06FC8480@webmail.messagingengine.com> Message-ID: They are being inserted into a database but the db doesn't recognize that as a number. So I have to convert it to -0.00007800825 before the insert. On Wed, Jul 23, 2014 at 2:36 PM, Larry Leszczynski wrote: > Hi Robert - > > > OK, I'm parsing through a bunch of data. Occasionally I get something > > like > > : > > $State="-7.7800825e-05" > > > > Usually the "e" is capital ( I don't know why this product logs it this > > way > > ). When the Capital E goes through the if statements below it converts > > fine, but the lower case does not it seems... > > > > I have put in the following sections to convert this: > > > > $State =~ tr/e/E/; > > > > if ( $State =~ /E/ ) { > > $State2 = sprintf("%.10g", $State); > > $State=$State2; > > } > > if ( $State =~ /e/ ) { > > $State2 = sprintf("%.10g", $State); > > $State=$State2; > > } > > What are you trying to do with these values? If you use them in numeric > context, they work fine as-is, no matter if they have a "e" or "E": > > $ perl -de 0 > > Loading DB routines from perl5db.pl version 1.32 > Editor support available. > > Enter h or `h h' for help, or `man perldebug' for more help. > > main::(-e:1): 0 > DB<1> print 0 + "-7.7800825e-05" > -7.7800825e-05 > DB<2> print 0 + "-7.7800825E-05" > -7.7800825e-05 > > > Larry > _______________________________________________ > Denver-pm mailing list > Denver-pm at pm.org > http://mail.pm.org/mailman/listinfo/denver-pm > -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From larryl at emailplus.org Thu Jul 24 07:27:33 2014 From: larryl at emailplus.org (Larry Leszczynski) Date: Thu, 24 Jul 2014 08:27:33 -0600 Subject: [Denver-pm] Scientific Notation -> Dec????? In-Reply-To: References: <1406147768.27943.144957561.06FC8480@webmail.messagingengine.com> Message-ID: <1406212053.16589.145230161.1A7B2299@webmail.messagingengine.com> Hi Robert - On Wed, Jul 23, 2014, at 06:00 PM, Robert L. Harris wrote: > They are being inserted into a database but the db doesn't recognize that > as a number. So I have to convert it to -0.00007800825 before the > insert. I think you could just do: if ($State =~ /[Ee]/) { $State = printf "%.12f", $State; } E.g.: $ perl -e 'printf "%.12f\n", "-7.7800825E-05"' -0.000077800825 $ perl -e 'printf "%.12f\n", "-7.7800825e-05"' -0.000077800825 HTH, Larry > > > > On Wed, Jul 23, 2014 at 2:36 PM, Larry Leszczynski > wrote: > > > Hi Robert - > > > > > OK, I'm parsing through a bunch of data. Occasionally I get something > > > like > > > : > > > $State="-7.7800825e-05" > > > > > > Usually the "e" is capital ( I don't know why this product logs it this > > > way > > > ). When the Capital E goes through the if statements below it converts > > > fine, but the lower case does not it seems... > > > > > > I have put in the following sections to convert this: > > > > > > $State =~ tr/e/E/; > > > > > > if ( $State =~ /E/ ) { > > > $State2 = sprintf("%.10g", $State); > > > $State=$State2; > > > } > > > if ( $State =~ /e/ ) { > > > $State2 = sprintf("%.10g", $State); > > > $State=$State2; > > > } > > > > What are you trying to do with these values? If you use them in numeric > > context, they work fine as-is, no matter if they have a "e" or "E": > > > > $ perl -de 0 > > > > Loading DB routines from perl5db.pl version 1.32 > > Editor support available. > > > > Enter h or `h h' for help, or `man perldebug' for more help. > > > > main::(-e:1): 0 > > DB<1> print 0 + "-7.7800825e-05" > > -7.7800825e-05 > > DB<2> print 0 + "-7.7800825E-05" > > -7.7800825e-05 > > > > > > Larry > > _______________________________________________ > > Denver-pm mailing list > > Denver-pm at pm.org > > http://mail.pm.org/mailman/listinfo/denver-pm > > > > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar From robert.l.harris at gmail.com Thu Jul 24 08:17:05 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Thu, 24 Jul 2014 09:17:05 -0600 Subject: [Denver-pm] Scientific Notation -> Dec????? In-Reply-To: <1406212053.16589.145230161.1A7B2299@webmail.messagingengine.com> References: <1406147768.27943.144957561.06FC8480@webmail.messagingengine.com> <1406212053.16589.145230161.1A7B2299@webmail.messagingengine.com> Message-ID: I'm pretty sure I tried that except with the sprintf ( the examples I found online only had sprint instead of printf ) and no change but I'll definitely try again. Thanks On Thu, Jul 24, 2014 at 8:27 AM, Larry Leszczynski wrote: > Hi Robert - > > On Wed, Jul 23, 2014, at 06:00 PM, Robert L. Harris wrote: > > They are being inserted into a database but the db doesn't recognize that > > as a number. So I have to convert it to -0.00007800825 before the > > insert. > > I think you could just do: > > if ($State =~ /[Ee]/) { > $State = printf "%.12f", $State; > } > > E.g.: > > $ perl -e 'printf "%.12f\n", "-7.7800825E-05"' > -0.000077800825 > $ perl -e 'printf "%.12f\n", "-7.7800825e-05"' > -0.000077800825 > > > HTH, > Larry > > > > > > > > > > On Wed, Jul 23, 2014 at 2:36 PM, Larry Leszczynski > > > wrote: > > > > > Hi Robert - > > > > > > > OK, I'm parsing through a bunch of data. Occasionally I get > something > > > > like > > > > : > > > > $State="-7.7800825e-05" > > > > > > > > Usually the "e" is capital ( I don't know why this product logs it > this > > > > way > > > > ). When the Capital E goes through the if statements below it > converts > > > > fine, but the lower case does not it seems... > > > > > > > > I have put in the following sections to convert this: > > > > > > > > $State =~ tr/e/E/; > > > > > > > > if ( $State =~ /E/ ) { > > > > $State2 = sprintf("%.10g", $State); > > > > $State=$State2; > > > > } > > > > if ( $State =~ /e/ ) { > > > > $State2 = sprintf("%.10g", $State); > > > > $State=$State2; > > > > } > > > > > > What are you trying to do with these values? If you use them in > numeric > > > context, they work fine as-is, no matter if they have a "e" or "E": > > > > > > $ perl -de 0 > > > > > > Loading DB routines from perl5db.pl version 1.32 > > > Editor support available. > > > > > > Enter h or `h h' for help, or `man perldebug' for more help. > > > > > > main::(-e:1): 0 > > > DB<1> print 0 + "-7.7800825e-05" > > > -7.7800825e-05 > > > DB<2> print 0 + "-7.7800825E-05" > > > -7.7800825e-05 > > > > > > > > > Larry > > > _______________________________________________ > > > Denver-pm mailing list > > > Denver-pm at pm.org > > > http://mail.pm.org/mailman/listinfo/denver-pm > > > > > > > > > > > -- > > :wq! > > > --------------------------------------------------------------------------- > > Robert L. Harris > > > > DISCLAIMER: > > These are MY OPINIONS With Dreams To Be A King, > > ALONE. I speak for First One Should Be A Man > > no-one else. - Manowar > -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: From larryl at emailplus.org Thu Jul 24 08:25:34 2014 From: larryl at emailplus.org (Larry Leszczynski) Date: Thu, 24 Jul 2014 09:25:34 -0600 Subject: [Denver-pm] Scientific Notation -> Dec????? In-Reply-To: References: <1406147768.27943.144957561.06FC8480@webmail.messagingengine.com> <1406212053.16589.145230161.1A7B2299@webmail.messagingengine.com> Message-ID: <1406215534.12900.145254349.5F27FBB0@webmail.messagingengine.com> Oops, sorry - that should be sprintf, not printf: if ($State =~ /[Ee]/) { $State = sprintf "%.12f", $State; } On Thu, Jul 24, 2014, at 09:17 AM, Robert L. Harris wrote: > I'm pretty sure I tried that except with the sprintf ( the examples I > found > online only had sprint instead of printf ) and no change but I'll > definitely try again. > > Thanks > > > On Thu, Jul 24, 2014 at 8:27 AM, Larry Leszczynski > wrote: > > > Hi Robert - > > > > On Wed, Jul 23, 2014, at 06:00 PM, Robert L. Harris wrote: > > > They are being inserted into a database but the db doesn't recognize that > > > as a number. So I have to convert it to -0.00007800825 before the > > > insert. > > > > I think you could just do: > > > > if ($State =~ /[Ee]/) { > > $State = printf "%.12f", $State; > > } > > > > E.g.: > > > > $ perl -e 'printf "%.12f\n", "-7.7800825E-05"' > > -0.000077800825 > > $ perl -e 'printf "%.12f\n", "-7.7800825e-05"' > > -0.000077800825 > > > > > > HTH, > > Larry > > > > > > > > > > > > > > > > On Wed, Jul 23, 2014 at 2:36 PM, Larry Leszczynski > > > > > wrote: > > > > > > > Hi Robert - > > > > > > > > > OK, I'm parsing through a bunch of data. Occasionally I get > > something > > > > > like > > > > > : > > > > > $State="-7.7800825e-05" > > > > > > > > > > Usually the "e" is capital ( I don't know why this product logs it > > this > > > > > way > > > > > ). When the Capital E goes through the if statements below it > > converts > > > > > fine, but the lower case does not it seems... > > > > > > > > > > I have put in the following sections to convert this: > > > > > > > > > > $State =~ tr/e/E/; > > > > > > > > > > if ( $State =~ /E/ ) { > > > > > $State2 = sprintf("%.10g", $State); > > > > > $State=$State2; > > > > > } > > > > > if ( $State =~ /e/ ) { > > > > > $State2 = sprintf("%.10g", $State); > > > > > $State=$State2; > > > > > } > > > > > > > > What are you trying to do with these values? If you use them in > > numeric > > > > context, they work fine as-is, no matter if they have a "e" or "E": > > > > > > > > $ perl -de 0 > > > > > > > > Loading DB routines from perl5db.pl version 1.32 > > > > Editor support available. > > > > > > > > Enter h or `h h' for help, or `man perldebug' for more help. > > > > > > > > main::(-e:1): 0 > > > > DB<1> print 0 + "-7.7800825e-05" > > > > -7.7800825e-05 > > > > DB<2> print 0 + "-7.7800825E-05" > > > > -7.7800825e-05 > > > > > > > > > > > > Larry > > > > _______________________________________________ > > > > Denver-pm mailing list > > > > Denver-pm at pm.org > > > > http://mail.pm.org/mailman/listinfo/denver-pm > > > > > > > > > > > > > > > > -- > > > :wq! > > > > > --------------------------------------------------------------------------- > > > Robert L. Harris > > > > > > DISCLAIMER: > > > These are MY OPINIONS With Dreams To Be A King, > > > ALONE. I speak for First One Should Be A Man > > > no-one else. - Manowar > > > > > > -- > :wq! > --------------------------------------------------------------------------- > Robert L. Harris > > DISCLAIMER: > These are MY OPINIONS With Dreams To Be A King, > ALONE. I speak for First One Should Be A Man > no-one else. - Manowar From robert.l.harris at gmail.com Fri Jul 25 07:17:03 2014 From: robert.l.harris at gmail.com (Robert L. Harris) Date: Fri, 25 Jul 2014 08:17:03 -0600 Subject: [Denver-pm] Scientific Notation -> Dec????? In-Reply-To: <1406215534.12900.145254349.5F27FBB0@webmail.messagingengine.com> References: <1406147768.27943.144957561.06FC8480@webmail.messagingengine.com> <1406212053.16589.145230161.1A7B2299@webmail.messagingengine.com> <1406215534.12900.145254349.5F27FBB0@webmail.messagingengine.com> Message-ID: OK, That looks like it did it. Robert On Thu, Jul 24, 2014 at 9:25 AM, Larry Leszczynski wrote: > Oops, sorry - that should be sprintf, not printf: > > if ($State =~ /[Ee]/) { > $State = sprintf "%.12f", $State; > } > > > On Thu, Jul 24, 2014, at 09:17 AM, Robert L. Harris wrote: > > I'm pretty sure I tried that except with the sprintf ( the examples I > > found > > online only had sprint instead of printf ) and no change but I'll > > definitely try again. > > > > Thanks > > > > > > On Thu, Jul 24, 2014 at 8:27 AM, Larry Leszczynski > > > wrote: > > > > > Hi Robert - > > > > > > On Wed, Jul 23, 2014, at 06:00 PM, Robert L. Harris wrote: > > > > They are being inserted into a database but the db doesn't recognize > that > > > > as a number. So I have to convert it to -0.00007800825 before the > > > > insert. > > > > > > I think you could just do: > > > > > > if ($State =~ /[Ee]/) { > > > $State = printf "%.12f", $State; > > > } > > > > > > E.g.: > > > > > > $ perl -e 'printf "%.12f\n", "-7.7800825E-05"' > > > -0.000077800825 > > > $ perl -e 'printf "%.12f\n", "-7.7800825e-05"' > > > -0.000077800825 > > > > > > > > > HTH, > > > Larry > > > > > > > > > > > > > > > > > > > > > > On Wed, Jul 23, 2014 at 2:36 PM, Larry Leszczynski < > larryl at emailplus.org > > > > > > > > wrote: > > > > > > > > > Hi Robert - > > > > > > > > > > > OK, I'm parsing through a bunch of data. Occasionally I get > > > something > > > > > > like > > > > > > : > > > > > > $State="-7.7800825e-05" > > > > > > > > > > > > Usually the "e" is capital ( I don't know why this product logs > it > > > this > > > > > > way > > > > > > ). When the Capital E goes through the if statements below it > > > converts > > > > > > fine, but the lower case does not it seems... > > > > > > > > > > > > I have put in the following sections to convert this: > > > > > > > > > > > > $State =~ tr/e/E/; > > > > > > > > > > > > if ( $State =~ /E/ ) { > > > > > > $State2 = sprintf("%.10g", $State); > > > > > > $State=$State2; > > > > > > } > > > > > > if ( $State =~ /e/ ) { > > > > > > $State2 = sprintf("%.10g", $State); > > > > > > $State=$State2; > > > > > > } > > > > > > > > > > What are you trying to do with these values? If you use them in > > > numeric > > > > > context, they work fine as-is, no matter if they have a "e" or "E": > > > > > > > > > > $ perl -de 0 > > > > > > > > > > Loading DB routines from perl5db.pl version 1.32 > > > > > Editor support available. > > > > > > > > > > Enter h or `h h' for help, or `man perldebug' for more help. > > > > > > > > > > main::(-e:1): 0 > > > > > DB<1> print 0 + "-7.7800825e-05" > > > > > -7.7800825e-05 > > > > > DB<2> print 0 + "-7.7800825E-05" > > > > > -7.7800825e-05 > > > > > > > > > > > > > > > Larry > > > > > _______________________________________________ > > > > > Denver-pm mailing list > > > > > Denver-pm at pm.org > > > > > http://mail.pm.org/mailman/listinfo/denver-pm > > > > > > > > > > > > > > > > > > > > > -- > > > > :wq! > > > > > > > > --------------------------------------------------------------------------- > > > > Robert L. Harris > > > > > > > > DISCLAIMER: > > > > These are MY OPINIONS With Dreams To Be A King, > > > > ALONE. I speak for First One Should Be > A Man > > > > no-one else. - Manowar > > > > > > > > > > > -- > > :wq! > > > --------------------------------------------------------------------------- > > Robert L. Harris > > > > DISCLAIMER: > > These are MY OPINIONS With Dreams To Be A King, > > ALONE. I speak for First One Should Be A Man > > no-one else. - Manowar > -- :wq! --------------------------------------------------------------------------- Robert L. Harris DISCLAIMER: These are MY OPINIONS With Dreams To Be A King, ALONE. I speak for First One Should Be A Man no-one else. - Manowar -------------- next part -------------- An HTML attachment was scrubbed... URL: