RE: elsif issues ....still
I haven't had the chance to run it... work, Thanks, guess I need to read up on this a bit more :o) r, james -Original Message- From: zsdc [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 7:58 AM To: Lile, James AZ2 (VAW-115) Cc: 'Catriona Wordsworth'; [EMAIL PROTECTED] Subject: Re: elsif issues still Lile, James AZ2 (VAW-115) wrote: Someone correct me if I am wrong, the numbers in quotes are being read as strings and not numbers, or numbers not strings. The == works with numbers, and the quotes are for strings. I think that the way you have it set up, the number one is returning true when the $variable is defined. Numbers in quotes are strings but in the numerical context (which is provided by the numerical equality operator == here) they are converted to numbers on the fly (non-number strings being 0), so that's not the issue here. Besides, if you run this sample code, you'll see that it works just fine. -zsdc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Formatting integer input: use the sprintf() in perlfunc - Perl builtin functions
Sara, whenever you need to do any special formatting like this, especially numbers, use the sprintf() in perlfunc - Perl builtin functions for your case, try this: print sprintf(%05.02f\n, 4.5 ); 04.50 there are 2 other print formatters: report and here documents. I don't use the report method because I prefer the here documents. A here document is very nice, yet hardly documented within perl. It involves just a TAG and a 2 special rules, here's and example: print MY_TAG; I can put anything in here and it will be exactly that. I can put the variable three=$three, I can put @vars in here. Everything expands. What's great is that there isn't all that print ... with special characters! The above statement could require some escaping of the single quote in print statements. Now, The 2 rules: #1 - the and the tag name MY_TAG must be together, ie, no spacing. #2 - the end tag MUST be in column 1 and nothing else, ie, no end ; so here's the end of this. MY_TAG You can store the here doc as a variable: my $message = MY_TAG; stuf MY_TAG cheers, -stuart -Original Message- From: Sara [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 20, 2003 1:21 PM To: beginperl Subject: Formatting integer input $one = 2.5; $two = 2; $three = $one + $two; print $three; # prints 4.5 I want 4.5 in proper format as 04.05 Any ideas? Thanks, Sara. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[PBML] PLEASE USE [PBML] in your subject line
hi peep's I don't post often but what i have found is that alot of you do not put [PBML] in your subject lines, i get your posting direct to my trash without it and i would very much like to read your posting and responses but with all the spam rubbish around at the moment this is the best way i have found to sort my mail. thank you brad -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [PBML] PLEASE USE [PBML] in your subject line
hi peep's I don't post often but what i have found is that alot of you do not put [PBML] in your subject lines, i get your posting direct to my trash I don't remember reading that in the handbook anywhere, heh. Since when are we supposed to write specific things in the subject? without it and i would very much like to read your posting and responses but with all the spam rubbish around at the moment this is the best way i Filter mail based on some other rule like messages that do not contain 'To unsubscribe, e-mail: [EMAIL PROTECTED]'.. have found to sort my mail. I sort by mailing list. On the server side of thngs, I have SpamAssassin running which catches and deletes a lot of my mail for me :) Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Re: [PBML] PLEASE USE [PBML] in your subject line
brad wrote: I don't post often but what i have found is that alot of you do not put [PBML] in your subject lines, i get your posting direct to my trash without it and i would very much like to read your posting and responses but with all the spam rubbish around at the moment this is the best way i have found to sort my mail. You seem to be confusing [EMAIL PROTECTED] with [EMAIL PROTECTED], which indeed has [PBML] in the subject of every message. Not that it's on-topic, but every message posted here contains /[EMAIL PROTECTED]/ at least thirteen times, which seems to be quite a good clue that it's somehow related to the [EMAIL PROTECTED] mailing list. (By the way, it's not [EMAIL PROTECTED], but [EMAIL PROTECTED], so your acronym should probably be [PBCML], [BCPML], [BCPOML] or something like that.) -zsdc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [PBML] PLEASE USE [PBML] in your subject line
-Original Message- From: Dennis Stout [EMAIL PROTECTED] To: brad [EMAIL PROTECTED], [EMAIL PROTECTED] Date: Fri, 22 Aug 2003 07:33:44 -0800 Subject: Re: [PBML] PLEASE USE [PBML] in your subject line hi peep's I don't post often but what i have found is that alot of you do not put [PBML] in your subject lines, i get your posting direct to my trash I don't remember reading that in the handbook anywhere, heh. Since when are we supposed to write specific things in the subject? without it and i would very much like to read your posting and responses but with all the spam rubbish around at the moment this is the best way i Filter mail based on some other rule like messages that do not contain 'To unsubscribe, e-mail: [EMAIL PROTECTED]'.. have found to sort my mail. I sort by mailing list. On the server side of thngs, I have SpamAssassin running which catches and deletes a lot of my mail for me :) Dennis sorry everyone i just realised i am on two lists (doh!) i will adjust my settings -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Secure Form Submission
On Fri, 22 Aug 2003 05:48:14 +, [EMAIL PROTECTED] (Greenhalgh David) wrote: Hi All, I need to implement a form that is submitted securely. My client does not have access to SSL on his host. I was thinking in terms of a session cookie with a client side RC4 encrypt and a decrypt in the Perl script. Do peoople here consider that to be a secure scenario, or is there another method that you could recommend? The encryption needs to be reversible. There is a method using javascript http://sourceforge.net/projects/perl-md5-login/ It sends a timed out temporary key, which some javascript uses to encrypt the post. It's soo much better to use SSL. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: disable back button
A page with no cache is awful. Tell me I can't use the back button on your site and I won't visit it. Bad idea to disable back button. -rm- - Original Message - From: Octavian Rasnita [EMAIL PROTECTED] To: Catriona Wordsworth [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, August 20, 2003 4:58 AM Subject: Re: disable back button You cannot disable the back button and the keyboard hotkey for this task from a perl script. You might need to use a client side program, like a Javascript one. However, you can make a page not to cache, and to expire immidiately, and this way if a visitor will press the back button the page won't be shown automaticly. However, they will be asked if they want to resend the data to the server and if the visitors will answer 'yes', the browser will resend it with no problem. You need to use this method, and also check on the server that the data was not submitted for a second time. To print the http headers for not allowing caching and to set the expiration date to immidiately expire, use something like: print EOF; Content-type: text/html Cache-control: no-cache Pragma: no-cache Expires: Thu, 01-Jan-2033 01:01:01 GMT htmlhead ... /html EOF teddy.fcc.ro [EMAIL PROTECTED] - Original Message - From: Catriona Wordsworth [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 20, 2003 7:38 AM Subject: disable back button Hi guys, pretty simple stuff I hope, but can someone tell me how to disable the back button in my perl script? thanks regards Cat -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Secure Form Submission
It seems like it should be secure. I am assuming the session cookie would store the server's public key? or some such? My question would be how do you implement an RC4 encryption (or any encryption other than the built-in SSL) on the client side? Possibly a Java applet with the encryption built-in? I suppose you could implement an encryption algorithm in javascript and then just call that via a form's onSubmit, but how would you generate a random number (built into javascript?)... yikes thats a lot of javascript :-)... and at that point you would also have to generate a private key on the client side, and send the corresponding public key to the server... and this would have to be done each time which could get slow... That was basically the plan, use the cookie to transport the key. Your comment about a lot of Javascript is precisely the daunting part. I saw in your other post about the limited IPs, if this really is a temp solution, the implementation difficulty still might suggest springing for extra hosting, or the similar until the upgrade is in place... Now there's a thought, a Summer Sale. I think I may even do it that way. Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Parlsax parsing problem
Hello, while trying to parse a large XML document i found a strange behaviour of the Parser Module(s) (XML::Parser:PerlSAX, XML::Parser, XML::Parser::Expat If my file XML file is larger then 65536 bytes the actual character string is interrupted and a whitespace is added. For Example DATASET DATA![CDATA[NOVDEC_B]]/DATA DATA![CDATA[November\December]]/DATA DATA![CDATA[Nov\Dec]]/DATA DATA![CDATA[01.11.]]/DATA DATA![CDATA[11]]/DATA DATA![CDATA[begin_2month]]/DATA DATA![CDATA[11]]/DATA /DATASET if now Novemver\December is at the 65536 border the String is splitted in Nov WHITESPACE ember\December Any ideas how to avoid /fix that problem Thanks in advance Regards Kurt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: only first checked item passed
Try (@rows)=$sth-fetchrow_array; Not @rows=$sth-fetchrow_array; José. -Original Message- From: Prachi Shah [mailto:[EMAIL PROTECTED] Sent: Thursday, August 21, 2003 11:06 PM To: [EMAIL PROTECTED] Subject: only first checked item passed Hi all, I have a CGI script which does a select on a database and builds a checkbox group iterating through the result of the select. The problem is when a user submits the form, only the first checked item in the checkbox group is passed. Below is the snippet of the perl code that generates the checkbox group. Please advise me if there is anything I am doing wrong. Any help is appreciated. Thanks, Prachi. ### cut code if (!$sth) { $sth = $dbh-prepare(SELECT * FROM . $schema . dberge_ranges WHERE chrom = ? . AND start_pt = ? AND stop_pt = ? ORDER BY id, start_pt); } $sth-execute($chr, $stp, $st); my(@row) = $sth-fetchrow_array; #print @row\n; if ([EMAIL PROTECTED]) { print $q-strong(No results and Expression data found\n), $q-br; }else { print $q-strong(Experimental results of gene expression), $q-br; print $q-start_form(-action = $dberge_url); print $q-br; print $q-start_table({-border=1}), $q-Tr, $q-td(ExperimentID Assay), $q-td(range affected); my $pid = 0; while (@row) { $row[3] = commify($row[3]); $row[4] = commify($row[4]); if ($pid == $row[0]) { #same variant another range if ($row[3] ne $row[4]) { print $q-br, $row[2] $row[3] - $row[4]; }else { print $q-br, $row[2] $row[3]; } }else { #new dberge entry print $q-Tr; print $q-td( $q-checkbox(-name='id', -value=$row[0], -label=$row[0] $row[1])); if ($row[3] ne $row[4]) { print $q-td, $row[2] $row[3] - $row[4]; #may continue }else { print $q-td, $row[2] $row[3]; } } $pid = $row[0]; @row = $sth-fetchrow_array; } print $q-br; print $q-end_table; print $q-br; print $q-hidden(mode, Submit query), $q-hidden(disp,All data); print $q-submit(-name=View, -value=Submit); end cut code ### _ Chat privately with Bon Jovi, Seal, Bow Wow, or Mary J Blige using MSN Messenger! http://www5.msnmessenger-download.com/imastar/default.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Trying to open a word document on the shell
I am trying to open a document as below #!/usr/local/bin/perl -w use Tk; my $mw = new MainWindow(); my $filename=$mw-getOpenFile(-filetypes=[['WinWord','winword.exe']]); system($filename john.doc); But it says it cannot find the $filename path the $filename form is C:/Program Files/Microsoft Office/Office/WINWORD.EXE How can i overcome this problem? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Parlsax parsing problem
Kurt Klinner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, while trying to parse a large XML document i found a strange behaviour of the Parser Module(s) (XML::Parser:PerlSAX, XML::Parser, XML::Parser::Expat If my file XML file is larger then 65536 bytes the actual character string is interrupted and a whitespace is added. For Example DATASET DATA![CDATA[NOVDEC_B]]/DATA DATA![CDATA[November\December]]/DATA DATA![CDATA[Nov\Dec]]/DATA DATA![CDATA[01.11.]]/DATA DATA![CDATA[11]]/DATA DATA![CDATA[begin_2month]]/DATA DATA![CDATA[11]]/DATA /DATASET if now Novemver\December is at the 65536 border the String is splitted in Nov WHITESPACE ember\December Hi Kurt, Not sure if this is your problem, but it seems to be something that trips people up. If your using a Char handler for pasing your xml you might be surprised to learn that it won't always contain the full text from a CDATA section like you descibe. Sometimes it will be called twice firstly with the first half of the data, and again with the second half. Your code need to ensure you cope with the behaviour. To quote the XML::Parser documentation ... Char (Expat, String) This event is generated when non-markup is recognized. The non-markup sequence of characters is in String. A single non-markup sequence of characters may generate multiple calls to this handler. Whatever the encoding of the string in the original document, this is given to the handler in UTF-8. ... Are you sure you're joining your CDATA correctly Post your code if this hasn't helped. Cheers, Rob Any ideas how to avoid /fix that problem Thanks in advance Regards Kurt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Changing case of the first letter of words in string
I want to make the case of the first letter of all the words in a selected string to upper case. The code s/\b(\w+)/\u$1\E/g; enables me to do this for the whole document. But the string I want to match and operate on is all instances of text following the string SCTN: as in SCTN: News Analysis or SCTN: Special Report But when I try s/(SCTN:\s*)\b(\w+)/$1\u$2\E/g; nothing seems to change? : ( Bis --
Re: only first checked item passed
Nyimi == Nyimi Jose [EMAIL PROTECTED] writes: Nyimi Try Nyimi (@rows)=$sth-fetchrow_array; Nyimi Not Nyimi @rows=$sth-fetchrow_array; Doesn't make a bit of difference. Useless parens there. Makes a difference only in: ($foo) = .. vs $foo = .. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: only first checked item passed
So, any other ideas? Original Message Follows From: [EMAIL PROTECTED] (Randal L. Schwartz) To: [EMAIL PROTECTED] Subject: Re: only first checked item passed Date: 22 Aug 2003 07:12:24 -0700 Nyimi == Nyimi Jose [EMAIL PROTECTED] writes: Nyimi Try Nyimi (@rows)=$sth-fetchrow_array; Nyimi Not Nyimi @rows=$sth-fetchrow_array; Doesn't make a bit of difference. Useless parens there. Makes a difference only in: ($foo) = .. vs $foo = .. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN 8: Get 6 months for $9.95/month. http://join.msn.com/?page=dept/dialup -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: only first checked item passed
Prachi Shah wrote: Hi all, I have a CGI script which does a select on a database and builds a checkbox group iterating through the result of the select. The problem is when a user submits the form, only the first checked item in the checkbox group is passed. How do you know only the first checked item is being passed? How are you retrieving the parameter values? I assume you're seeing multiple checkboxes on the screen, so your generate code is probably OK. All the checkboxes have the same name, so you need to call param() in list context to get them all. If you call it in scalar context, you're only going to get the first. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how do I file lock for a form?
Hi. When a user hits submit many times after completeing a form, I get multiple (duplicate) entries in my spreadsheet. I've read that I can add a hidden field with a unique identifier to lock the file so this won't happen. I don't know how to do this - can anyone explain/direct me to a good info source (I am a newbie). Thanks, Gregg - Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software
RE: About Shift
Yes because your not shifting any values just a memory address. Here this might help --- When you do your sub call mysub ($myvar, $myvar2) An array is created in your subroutine that holds both those values. It is called @_. So in the sub @_ holds ($myvar, $myvar2), So $_[0] = $myvar. All shift does is empty the @_ array So my $newvar = shift Would give $newvar the value of $_[0] and remove it from the array So now the array @_ only holds $myvar2 and it is now $_[0]. The first varirable was shifted out of the array. Now as to your question. Your not passing an array just the memory location of it. Which is something along the lines of... ARRAY(0x185f3fc) That is it. Just that string is all that is in $value of your sub routine. Just that string which happens to be an address to the REAL array. You can test this. Simply add a print statement to your routine that prints $value and you will see what I mean. When you want to use the values of the array you dereferance it which is why you are using double $$ or @$ Which reads as the string value contained at this mememory address. So $$value[0] literaly means use the array item 0 contained at the memory address of $value. Its confusing. You should read up on refreances. Or if your not ready to use them pass the whole array by removing the \ in the sub call. This will send the entire array to your subroutine actually it passes a copy of the array so that changes made in the sub don't affect the real array. You could also leave the array as a global variable and not pass it at all and just use the array like you would anywhere else. BUY learning perl by oriely. You can blow through it in an afteroon and it will clear up a lot of this a lot better then I can explain. I am Ccing the list so that others can contribute. Also if others are having the same questions you are having it will benefit them. I don't mind you mailing me directly but if its perl related send a copy to the list for everyones benefit. I think I just confused my self :) Paul -Original Message- From: Antonio Jose [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 11:20 AM To: [EMAIL PROTECTED] Subject: About Shift Hello Can I use shift if I want to manipulate and to do calculus with the vector value?. In the case down it's possible becuase I am not going to do something with it, only print the length. like this (example): #!/usr/bin/perl use strict; use warnings; sub suavizar { my ( $prof, $value ) = ( shift, shift ); # same as ( $_[0], $_[1] ); $long = . scalar (@$value) . ; print Length of value = long \n; # @$value my $nada = 0; for ($i=0; $i = $long; ++$i) { $nada = $value[$i] + $nada; } print addition = $nada[$i]\n; (arrary referenced in $value) } my $prof = 'some variable'; my @value = (item1,item2,item3); suavizar ( $prof, [EMAIL PROTECTED] ); Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I file lock for a form?
Hi. When a user hits submit many times after completeing a form, I get multiple (duplicate) entries in my spreadsheet. I've read that I can add a hidden field with a unique identifier to lock the file so this won't happen. I don't know how to do this - can anyone explain/direct me to a good info source (I am a newbie). Thanks, Gregg - Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software I've had this issue also, no matter how often YOU put the ONLY click once somebody will do it twice, or more. I found a way by using DHTML to make it so that the SUBMIT button only works ONCE, I found it on the Dynamic Drive web site here: http://www.dynamicdrive.com/ They have some excellent ways using JS to stop the problems you are having.. The only problem that you can run into, is browser levels, if the user is on an older one the code doesn't work. So if you have some controls on this, like it is a company Intranet, as here, then you can use their ideas, try to use their Cross browser techniques. Happy coding. -- Rich Parker -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Trying to open a word document on the shell
Hmmm... How did you send your message to [EMAIL PROTECTED] My answer was bounced... Anyway, I'm sending it once again, this time to [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: system($filename john.doc); But it says it cannot find the $filename path the $filename form is C:/Program Files/Microsoft Office/Office/WINWORD.EXE How can i overcome this problem? I have no idea how does the Windows shell work, and how does it handle quotes and escapes, but the problem is caused probably by the white space in your path. Here are my suggestions: system $filename, john.doc; or: system qq($filename john.doc); Maybe try escaping every space in your $filename before: $filename =~ s/ /\\ /g; I haven't tested it myself. -zsdc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble with math... driving me nuts.
This seems to work, although there are some odd line returns and '0' is being returned as '0.' Still, I can work around that, THANKS! |-+ | | zsdc [EMAIL PROTECTED]| | || | | 08/21/2003 03:28 | | | PM | | || |-+ --| | | | To: [EMAIL PROTECTED] | | cc: [EMAIL PROTECTED] | | Subject: Re: trouble with math... driving me nuts. | --| [EMAIL PROTECTED] wrote: print 37.75 - 33.67 - 4.08 ; STDIN; I find these things all the time. Is there a particular module I can use to fix these things? Take a look at Math::BigFloat, it's an arbitrary length float math package: #!/usr/bin/perl -wl use Math::BigFloat; $x = 37.75; print $x - 33.67 - 4.08; $x = Math::BigFloat-new('37.75'); print $x - 33.67 - 4.08; ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. OK, I won't tell anyone. -zsdc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: trouble with math... driving me nuts.
True, it's not a Perl issue (I've been able to duplicate the problem in C, and Scheme), but I'm looking for a Perl solution. Math::BigFloat seems to work well enough. Thanks, Peter |-+ | | Levon Barker | | | [EMAIL PROTECTED] | | || | | 08/21/2003 03:09 | | | PM | | || |-+ --| | | | To: [EMAIL PROTECTED], [EMAIL PROTECTED] | | cc: | | Subject: RE: trouble with math... driving me nuts. | --| Hi Peter, This is a floating point issue. It is a general computing problem and not just subject to Perl. In decimal form the result is -0.0017763568. Generally thats usually acurate enough. Otherwise you could truncate it or round it to the nearest quadrabillionth. Cheers, Levon Barker -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, August 21, 2003 3:06 PM To: [EMAIL PROTECTED] Subject: trouble with math... driving me nuts. Luckily I was easily able to recreate the problem. See code below: print 37.75 - 33.67 - 4.08 ; STDIN; I find these things all the time. Is there a particular module I can use to fix these things? Output is -1.77635683940025e-015 Should be 0 Running on Win2000 / Intel P3 -Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Read dir / sort
I have a program that would read a directory and then do some renaming. Up until recently it always seem to read by oldest file first to newest. Which is great because my renaming involves incrementing a counter and placing that count in each file. So if the order was changed the program will break. Which it did. So two questions why is it reading the directories different now? How can I have it read the directory with oldest file first. Here is the sub routine. sub getfiles { my ($amcount, $pmcount); opendir ( DH, '//sco1/pm6/reports') or die (Can not open directory\n); foreach ( readdir (DH) ) { next unless /^Sj/; print $_\n; #changefilename( ( stat( //sco1/pm6/reports/$_ ) ) [9], $_ ); } die; foreach (keys %files){ my $counter; foreach ( @ { $files {$_} } ) { $counter++; $_-[1] =~ s/_/_($counter)_/; print $_-[1]\n; # rename //sco1/pm6/reports/$_-[0], ./$_-[1] or die ( NO! $!\n ); } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Read dir / sort
WTF now its working with no changes to the program.. This is very frustrating. Is perl some how looking at the way the directory was last sorted in my Ms window even though its pulling it from a UNIX server? -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 2:30 PM To: [EMAIL PROTECTED] Subject: Read dir / sort I have a program that would read a directory and then do some renaming. Up until recently it always seem to read by oldest file first to newest. Which is great because my renaming involves incrementing a counter and placing that count in each file. So if the order was changed the program will break. Which it did. So two questions why is it reading the directories different now? How can I have it read the directory with oldest file first. Here is the sub routine. sub getfiles { my ($amcount, $pmcount); opendir ( DH, '//sco1/pm6/reports') or die (Can not open directory\n); foreach ( readdir (DH) ) { next unless /^Sj/; print $_\n; #changefilename( ( stat( //sco1/pm6/reports/$_ ) ) [9], $_ ); } die; foreach (keys %files){ my $counter; foreach ( @ { $files {$_} } ) { $counter++; $_-[1] =~ s/_/_($counter)_/; print $_-[1]\n; # rename //sco1/pm6/reports/$_-[0], ./$_-[1] or die ( NO! $!\n ); } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Read dir / sort
Ok tested that theory and it is exactly what it is doing. That is not a good thing. How can I force it to read the directory based on file date instead of the way windows last sorted it. That does not seem right to me that it would function like this. -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 2:36 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Read dir / sort WTF now its working with no changes to the program.. This is very frustrating. Is perl some how looking at the way the directory was last sorted in my Ms window even though its pulling it from a UNIX server? -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 2:30 PM To: [EMAIL PROTECTED] Subject: Read dir / sort I have a program that would read a directory and then do some renaming. Up until recently it always seem to read by oldest file first to newest. Which is great because my renaming involves incrementing a counter and placing that count in each file. So if the order was changed the program will break. Which it did. So two questions why is it reading the directories different now? How can I have it read the directory with oldest file first. Here is the sub routine. sub getfiles { my ($amcount, $pmcount); opendir ( DH, '//sco1/pm6/reports') or die (Can not open directory\n); foreach ( readdir (DH) ) { next unless /^Sj/; print $_\n; #changefilename( ( stat( //sco1/pm6/reports/$_ ) ) [9], $_ ); } die; foreach (keys %files){ my $counter; foreach ( @ { $files {$_} } ) { $counter++; $_-[1] =~ s/_/_($counter)_/; print $_-[1]\n; # rename //sco1/pm6/reports/$_-[0], ./$_-[1] or die ( NO! $!\n ); } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing case of the first letter of words in string
Bis wrote: I want to make the case of the first letter of all the words in a selected string to upper case. The code s/\b(\w+)/\u$1\E/g; enables me to do this for the whole document. But the string I want to match and operate on is all instances of text following the string SCTN: as in SCTN: News Analysis or SCTN: Special Report But when I try s/(SCTN:\s*)\b(\w+)/$1\u$2\E/g; nothing seems to change? : ( Bis My guess (without actually trying) is the word boundary marker (\b). Since you're grabbing all preceding whitespace you can't (in theory) expect it to find whitespace before your word. So... try this: s/(SCTN:\s*)(\w+)/$1\u$2\E/g; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Read dir / sort
Paul Kraus wrote: Ok tested that theory and it is exactly what it is doing. That is not a good thing. How can I force it to read the directory based on file date instead of the way windows last sorted it. That does not seem right to me that it would function like this. foreach ( readdir (DH) ) { Mildly tested (and ugly) but how 'bout replacing this with something to the effect of: foreach (sort { (stat(//sco1/pm6/reports/$b))[9] = (stat(//sco1/pm6/reports/$a))[9] } readdir (DH)) { : } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing case of the first letter of words in string
Bis [EMAIL PROTECTED] wrote: I want to make the case of the first letter of all the words in a selected string to upper case. The code s/\b(\w+)/\u$1\E/g; enables me to do this for the whole document. But the string I want to match and operate on is all instances of text following the string SCTN: as in SCTN: News Analysis or SCTN: Special Report But when I try s/(SCTN:\s*)\b(\w+)/$1\u$2\E/g; nothing seems to change? : ( That will only change the first letter of the first word after 'SCTN:'. That's what you're seeing, right? If you want to change *all* the words after SCTN: to start with uppercase (and leave the ones before it alone), maybe something like this: my $text = q(leave this alone SCTN: this isn't capitalized but should be); if (/SCTN:/) { my ($before, $after) = split /SCTN:/, $text, 2; $after =~ s/(\S+)/\u$1/g; $text = $before . 'SCTN:' . $after; } print $text; I used \S instead of \w in an attempt to handle contractions such as can't and don't, etc. Now I'd almost bet someone (John Krahn?) will come up with a more clever approach and make it into a one-liner. :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing case of the first letter of words in string
Bis wrote: I want to make the case of the first letter of all the words in a selected string to upper case. The code s/\b(\w+)/\u$1\E/g; enables me to do this for the whole document. But the string I want to match and operate on is all instances of text following the string SCTN: as in SCTN: News Analysis or SCTN: Special Report But when I try s/(SCTN:\s*)\b(\w+)/$1\u$2\E/g; nothing seems to change? : ( s{^SCTN:\s*(.*)}{ ($a = $1) =~ s[(\w+)][\u$1]g; $a }e; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble with math... driving me nuts.
[EMAIL PROTECTED] wrote: #!/usr/bin/perl -wl use Math::BigFloat; $x = 37.75; print $x - 33.67 - 4.08; $x = Math::BigFloat-new('37.75'); print $x - 33.67 - 4.08; This seems to work, although there are some odd line returns You mean the automatic \n with every print? It's because of the -l switch in the #! line. See perlrun(1) manpage: http://www.perldoc.com/perl5.8.0/pod/perlrun.html#-l%5boctnum%5d I like to use it in simple programs, as it makes them cleaner without all of those explicit newlines, but you can just remove the -l switch and have a standard print behavior. (Keep the -w, however, it turns on warnings. Or better yet use use warnings; pragma.) and '0' is being returned as '0.' Still, I can work around that, THANKS! Yes, indeed. I checked out the source of Math::BigFloat and unfortunately the class name is hardcoded all over the place (it's probably fixed in newer versions) so it's hard to subclass, but this is Perl, after all, so we can redefine the overloaded stringification operator in the Math::BigFloat class itself: use Math::BigFloat; { package Math::BigFloat; use overload '' = sub {(my $n = $_[0]-stringify) =~ s/\.$//; $n}; } Now it prints just 0 without the . at the end. But note that such a code will stop working if the stringify method in Math::BigFloat is ever renamed. Unlikely, but possible. It's probably not the most elegant way to program, still it's pretty cool. You could store the \{'Math::BigFloat::('} reference to have the original stringification method even if it's renamed (anyone knows if it's documented somewhere?) but it could introduce another problems with overload.pm implementation. The code I wrote gives a warning about the ( subroutine being redefined in overload.pm when the script is run with the -w switch, but (at least on my system) it doesn't print the warning if there's use warnings; instead of -w, which is better anyway. -zsdc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Read dir / sort
Paul Kraus wrote: WTF now its working with no changes to the program.. This is very frustrating. Is perl some how looking at the way the directory was last sorted in my Ms window even though its pulling it from a UNIX server? Perl isn't doing anything but calling the OS's underlying readdir(2) call. You shouldn't make any assumptions about the order in which readdir() returns files. If you need them in some particular order, read them and then sort them. -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 2:30 PM To: [EMAIL PROTECTED] Subject: Read dir / sort I have a program that would read a directory and then do some renaming. Up until recently it always seem to read by oldest file first to newest. Which is great because my renaming involves incrementing a counter and placing that count in each file. So if the order was changed the program will break. Which it did. So two questions why is it reading the directories different now? How can I have it read the directory with oldest file first. Here is the sub routine. sub getfiles { my ($amcount, $pmcount); opendir ( DH, '//sco1/pm6/reports') or die (Can not open directory\n); foreach ( readdir (DH) ) { next unless /^Sj/; print $_\n; #changefilename( ( stat( //sco1/pm6/reports/$_ ) ) [9], $_ ); } die; foreach (keys %files){ my $counter; foreach ( @ { $files {$_} } ) { $counter++; $_-[1] =~ s/_/_($counter)_/; print $_-[1]\n; # rename //sco1/pm6/reports/$_-[0], ./$_-[1] or die ( NO! $!\n ); } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Read dir / sort
Paul Kraus wrote: I have a program that would read a directory and then do some renaming. Up until recently it always seem to read by oldest file first to newest. Which is great because my renaming involves incrementing a counter and placing that count in each file. So if the order was changed the program will break. Which it did. So two questions why is it reading the directories different now? Files are not stored on the file system in any predefined order. If they appear to be in some order then that is just a coincidence. If you want the file names in a certain order then you will have to sort them yourself. How can I have it read the directory with oldest file first. my $dir = '//sco1/pm6/reports'; opendir DH, $dir or die Can not open $dir: $!; my @files = map $_-[0], sort { $b-[1] = $a-[1] } map [ $_, -M $dir/$_ ], grep /^Sj/, readdir DH; closedir DH; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Parlsax parsing problem
Kurt Klinner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, while trying to parse a large XML document i found a strange behaviour of the Parser Module(s) (XML::Parser:PerlSAX, XML::Parser, XML::Parser::Expat If my file XML file is larger then 65536 bytes the actual character string is interrupted and a whitespace is added. Any ideas how to avoid /fix that problem As noted in another post, per the SAX spec a parser may fire multiple characters() events for a single set of characters defined in a XML node. All my SAX filters use XML::Filter::BufferText as its first filter. This filter put all characters() in one event: http://search.cpan.org/author/RBERJON/XML-Filter-BufferText-1.01/BufferText.pm That dosen't explain why there is a space at that point. My guess would be that you are in fact appending a space to each of your characters() events before you forward the node down stream. Perhaps you could post that handler? I am very curious. Could you post an example program? You could generate 70k of sample cdata by using the 'x' operator: $doc = 'doc![CDATA[' . 'abcdefhijklm' x 50_000 . ']]/doc'; Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing case of the first letter of words in string
Thanks Gabriel - your suggested code s/(SCTN:\s*)(\w+)/$1\u$2\E/g; is an improvement - it does capitalise the first letter - but only of the first word after SCTN: so i get something like SCTN: This is a section name What I need is SCTN: This Is A Section Name hope that makes sense! :) --- Gabriel Cooper [EMAIL PROTECTED] wrote: Bis wrote: I want to make the case of the first letter of all the words in a selected string to upper case. The code s/\b(\w+)/\u$1\E/g; enables me to do this for the whole document. But the string I want to match and operate on is all instances of text following the string SCTN: as in SCTN: News Analysis or SCTN: Special Report But when I try s/(SCTN:\s*)\b(\w+)/$1\u$2\E/g; nothing seems to change? : ( Bis My guess (without actually trying) is the word boundary marker (\b). Since you're grabbing all preceding whitespace you can't (in theory) expect it to find whitespace before your word. So... try this: s/(SCTN:\s*)(\w+)/$1\u$2\E/g; Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing case of the first letter of words in string
On Friday, August 22, 2003, at 05:06 PM, bis wrote: Thanks Gabriel - your suggested code s/(SCTN:\s*)(\w+)/$1\u$2\E/g; is an improvement - it does capitalise the first letter - but only of the first word after SCTN: so i get something like SCTN: This is a section name What I need is SCTN: This Is A Section Name hope that makes sense! :) Well, let's see if we can get a little closer: s/(SCTN:\s*)(.+)$/join '', $1, map { ucfirst $_ } split /( )/, $2/ge; See if that helps any. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
reinstall PERL
How to repair Perl instalation on OBSD 3.3 stable? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]