replacing numbers around a decimal
I am creating a little calculator that is going to need to take a user entered number that will always have 2 decimal places (using sprintf). It could be 89562321.29 or it could be 101.00) and take the last 4 digits (with the period included, so five places) and do two things: 1)Store the number in a variable. For the two examples above that would be 21.29 and 01.00 respectively would be stored in their own variable x=21.29 or it could be x=01.00; and 2) replace the last 4 numbers (5 places) with 00.00 -- always. For the two examples above they would become 89562300.00 and 100.00. Can anyone point me in the right direction? Thanks, Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
listing modules installed with CPAN
Hello- How can I tell what modules I've installed using CPAN? When I type in 'b' or 'd' or 'm' I seem to get everything, I only want to know what modules / bundles I've installed using CPAN. Thanks in advance, Justin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: replacing numbers around a decimal
on wo, 16 okt 2002 20:03:31 GMT, Andrew Hughes wrote: I am creating a little calculator that is going to need to take a user entered number that will always have 2 decimal places (using sprintf). It could be 89562321.29 or it could be 101.00) and take the last 4 digits (with the period included, so five places) and do two things: 1)Store the number in a variable. For the two examples above that would be 21.29 and 01.00 respectively would be stored in their own variable x=21.29 or it could be x=01.00; and 2) replace the last 4 numbers (5 places) with 00.00 -- always. For the two examples above they would become 89562300.00 and 100.00. Can anyone point me in the right direction? my $number = 89562321.29; my $big = int($number/100)*100; my $small = $number - $big; printf(%.2f - %05.2f\n, $big, $small); -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: replacing numbers around a decimal
Thanks Felix. I actually used $start_discounted_gift_cert = ($total_start) * ($start_discounted_gift_cert_of_total); $start_discounted_gift_cert = sprintf(%8.2f,$start_discounted_gift_cert); $giftcert_remainder_first = substr($start_discounted_gift_cert, -5); $giftcert_remainder_first = sprintf(%8.2f,$giftcert_remainder_first); substr() works perfectly. Even though substr() works well, i believe that it was created to be used with strings not numbers. I know that you are all busy, but can anyone point out anything fundamentally wrong with my approach? Thanks, Andrew -Original Message- From: Felix Geerinckx [mailto:felix_geerinckx;hotmail.com] Sent: Thursday, October 17, 2002 3:06 PM To: [EMAIL PROTECTED] Subject: Re: replacing numbers around a decimal on wo, 16 okt 2002 20:03:31 GMT, Andrew Hughes wrote: I am creating a little calculator that is going to need to take a user entered number that will always have 2 decimal places (using sprintf). It could be 89562321.29 or it could be 101.00) and take the last 4 digits (with the period included, so five places) and do two things: 1)Store the number in a variable. For the two examples above that would be 21.29 and 01.00 respectively would be stored in their own variable x=21.29 or it could be x=01.00; and 2) replace the last 4 numbers (5 places) with 00.00 -- always. For the two examples above they would become 89562300.00 and 100.00. Can anyone point me in the right direction? my $number = 89562321.29; my $big = int($number/100)*100; my $small = $number - $big; printf(%.2f - %05.2f\n, $big, $small); -- felix -- 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: [CGI ERR] Global symbol requires explicit package name ...
On Wed, 16 Oct 2002 at 19:33, Colby opined: [snip] C:Global symbol requires explicit package name at ./myscript.cgi line C:60, 70, 90, 108 [snip] C:I've gone over the code with a fine-tooth comb as it were, checked for C:the usual (missing semi-colons, right parenthesis/curly braces, etc C:...) and found nothing amiss. I haven't run the script through the C:Perl debugger yet and I am not able to do so on the web hosting C:company's server because they don't allow telnet/SSH. how long is the code? it would help if we could take a gander at it. perhaps you could try another small test script and see if it does the same thing (if your original script is too long)? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Weekly list FAQ posting
NAME beginners-faq - FAQ for the beginners-cgi mailing list 1 - Administriva 1.1 - I'm not subscribed - how do I subscribe? Send mail to [EMAIL PROTECTED] You can also specify your subscription email address by sending email to (assuming [EMAIL PROTECTED] is your email address): [EMAIL PROTECTED]. 1.2 - How do I unsubscribe? Now, why would you want to do that? Send mail to [EMAIL PROTECTED], and wait for a response. Once you reply to the response, you'll be unsubscribed. If that doesn't work, find the email address which you are subscribed from and send an email like the following (let's assume your email is [EMAIL PROTECTED]): [EMAIL PROTECTED] 1.3 - There is too much traffic on this list. Is there a digest? Yes. To subscribe to the digest version of this list send an email to: [EMAIL PROTECTED] To unsubscribe from the digest, send an email to: [EMAIL PROTECTED] 1.4 - Is there an archive on the web? Yes, there is. It is located at: http://archive.develooper.com/beginners-cgi%40perl.org/ 1.5 - How can I get this FAQ? This document will be emailed to the list once a month, and will be available online in the archives, and at http://beginners.perl.org/ 1.6 - I don't see something in the FAQ, how can I make a suggestion? Send an email to [EMAIL PROTECTED] with your suggestion. 1.7 - Is there a supporting website for this list? Yes, there is. It is located at: http://beginners.perl.org/ 1.8 - Who owns this list? Who do I complain to? Casey West owns the beginners-cgi list. You can contact him at [EMAIL PROTECTED] 1.9 - Who currently maintains the FAQ? Kevin Meltzer, who can be reached at the email address (for FAQ suggestions only) in question 1.6 1.10 - Who will maintain peace and flow on the list? Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large, yet padded, clue-sticks to maintain peace and order on the list. If you are privately emailed by one of these folks for flaming, being off-topic, etc... please listen to what they say. If you see a message sent to the list by one of these people saying that a thread is closed, do not continue to post to the list on that thread! If you do, you will not only meet face to face with a XQJ-37 nuclear powered pansexual roto-plooker, but you may also be taken off of the list. These people simply want to make sure the list stays topical, and above-all, useful to Perl/CGI beginners. 1.11 - When was this FAQ last updated? Sept 07, 2001 2 - Questions about the 'beginners-cgi' list. 2.1 - What is the list for? A list for beginning Perl programmers to ask questions in a friendly atmosphere. The topic of the list is, of course, CGI with Perl. 2.2 - What is this list _not_ for? * SPAM * Homework * Solicitation * Things that aren't Perl related * Non Perl/CGI questions or issues * Lemurs 2.3 - Are there any rules? Yes. As with most communities, there are rules. Not many, and ones that shouldn't need to be mentioned, but they are. * Be nice * No flaming * Have fun 2.4 - What topics are allowed on this list? Basically, if it has to do with Perl/CGI , then it is allowed. If your question has nothing at all to do with Perl/CGI, it will likely be ignored. 2.5 - I want to help, what should I do? Subscribe to the list! If you see a question which you can give an idiomatic and Good answer to, answer away! If you do not know the answer, wait for someone to answer, and learn a little. 2.6 - Is there anything I should keep in mind while answering? We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the beginner to the place in the FM they should R :) 2.7 - I don't want to post a question if it is in an FAQ. Where should I look first? Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it. It can save everyone time if you look in the Perl FAQs first, instead of having a list of people refer you to the Perl FAQs :) You can learn about 'perldoc' by typing: perldoc perldoc At your command prompt. You can also view documentation online at: http://www.perldoc.com and http://www.perl.com 3 - Other Resources 3.1 - What other websites may be useful to a beginner ? * Perl Home Page - http://www.perl.com * PerlMonks - http://www.perlmonks.org * Perldoc - http://www.perldoc.com * Perl Archives - http://www.perlarchives.com 3.2 - What resources may be harmful to a beginner? Beware of Perl4-like code-- You might find some script archives and unauthorized mirrors with old Perl4 versions of Selena Sol and Matt Wright scripts. Don't use those scripts. They are outdated and may even in some cases contain bugs or security problems since many may not have been updated in
[CGI ERR] Global symbol requires explicit package name ...
I have a CGI script accessing a MySQL DB via DBI, the script executes almost flawlessly on my home Linux box running Apache 1.3.26 and Perl 5.8.0 (with the usual modules installed and then some :) (The only complaint my computer gives is a warning related to the concatenation operator '.') However, the web host that I've just signed up with (running RH Linux with Apache 1.3.? and Perl 5.6.1) won't execute my script and returns the following errors when run from the command line: _ Global symbol requires explicit package name at ./myscript.cgi line 60, 70, 90, 108 _ I understand that that error usually means that when using '-w' and 'use strict;' that I haven't declared a variable using 'my $varname;' I don't have a variable that has no name or is and so the above error has really stumped me. I've gone over the code with a fine-tooth comb as it were, checked for the usual (missing semi-colons, right parenthesis/curly braces, etc ...) and found nothing amiss. I haven't run the script through the Perl debugger yet and I am not able to do so on the web hosting company's server because they don't allow telnet/SSH. Any ideas folks? Thanks in advance. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
radio_group Could you help me?
Hello, I'm Beatriz. I have a problem. Could you help me? I'he done an application to generate an index using an MySql table. When I see the CGI in the Internet Explorer I see the radio_group well only one of them is check, but if I show it in Netscape I show all radio checked. I send you the source. What can I do? ** while ($cod=$sth-fetchrow_array) { $abc=$conexion-prepare(SELECT Nombre FROM general where Codigo='$cod'); $abc-execute; $var=$abc-fetchrow_array; #print a({-href=http://10.195.6.91/cgi-bin/ficha2.pl#$cod,-target='_new'},$var ),br; print TR, td( radio_group(-name='indice', -value=$cod)), td(font color=#00 family=Verdana size=2 style=normal weight=normal, $var,/font), /TR; $abc-finish(); } $sth-finish(); ** Thank you, Beatriz Pd.Sorry for my bad english. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: listing modules installed with CPAN
On 17 Oct 2002 at 14:15, Justin Cook wrote: How can I tell what modules I've installed using CPAN? When I type in 'b' or 'd' or 'm' I seem to get everything, I only want to know what modules / bundles I've installed using CPAN. Read the section about autobundle in `perldoc CPAN`. William -- Lead Developer Knowmad Services Inc. || Internet Applications Database Integration http://www.knowmad.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: replacing numbers around a decimal
Hi Andrew, I think your approach should work fine as long as you put your data into a standard format. Perl doesn't differentiate between strings or numbers. A few suggestions: 1. encapsulate this code into a generic function, or method if you're doing OOP 2. use a constant or a variable for the offset instead of hard-coding the value (-5) e.g., sub get_offset_value { my ($number, $offset) = @_; die Invalid offset - $offset unless $offset =~ /^\d+$/; $offset++; $value = sprintf(%8.2f,$value); my $offset_value = substr($value, -$offset); $offset_value = sprintf(%8.2f,$offset_value); return $offset_value; } Good luck, William -- Lead Developer Knowmad Services Inc. || Internet Applications Database Integration http://www.knowmad.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
using CGI::SecureState with CGI::Pretty
if this message has came thru before, i am sorry and wont make a habit of it. hello, i would like to be able to use CGI::Pretty, with the html shortcuts along with CGI::SecureState. if i uncomment #use CGI::Pretty qw/:standard/; i get the following error:--- Undefined subroutine CGI::SecureState::cache at /var/www/cgi-bin/tscript line 17 end of error my question is: how do i use CGI::SecureState along with CGI::Pretty and also have acces to the html shortcuts provide by the standard CGI:: thanks randy perkins Here is the test script:-- #!/usr/bin/perl use CGI::SecureState; #use CGI::Pretty qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; my $cgi = new CGI::SecureState(-stateDir = '/tmp/testme', -mindSet = 'unforgetful'); my @whatever = qw/yes no maybe ok see ya/; $cgi-add(myparam =[@whatever]); my $param = $cgi-state_param(); my $url = $cgi-state_url(); print $cgi-header(); print a href=\$url\I am a stateful CGI session./a; # i used to be able to print a break like this, using a html shortcut #print br; # since using CGI::SecureState i have to print it like this print br; foreach($cgi-param('myparam')) { print $_,'br'; } $cgi-end_html; end of script -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
question about use MODULE
Hello, I wonder wether 'use module' compiles only once. I mean that all sebsequent calls don't involve compiling. Example: MyLib.pm package MyLib; use strict; use MyConfig; ## ## Code the uses MyConfig ## MyScript.pl use MyLib; use MyConfig; Will the 'use MyConfig' in the second file compile again? Thanks in advance