|
|
Up |
  |
|
|
  |
Author: Cosmic CruizerCosmic Cruizer
Date: May 7, 2008 19:39
Everyday I'm finding out more and more I can do with Win32::OLE(
|
| |
|
| |
1 Comment |
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: May 7, 2008 18:03
This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
4.1: Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?
Internally, your computer represents floating-point numbers in binary.
Digital (as in powers of two) computers cannot store all numbers
exactly. Some real numbers lose precision in the process. This is a
problem with how computers store numbers and affects all computer
languages, not just Perl.
perlnumber shows the gory details of number representations and
conversions.
To limit the number of decimal places in your numbers, you can use the
printf or sprintf function. See the "Floating Point Arithmetic" for more
details.
printf "%%.2f", 10/3;
my $number = sprintf "%%.2f", 10/3;
|
| Show full article (1.74Kb) |
|
no comments
|
|
  |
Author: xahleexahlee
Date: May 7, 2008 16:13
I'd like to introduce a blog post by Stephen Wolfram, on the design
process of Mathematica. In particular, he touches on the importance of
naming of functions.
• Ten Thousand Hours of Design Reviews (2008 Jan 10) by Stephen
Wolfram
http://blog.wolfram.com/2008/01/10/ten-thousand-hours-of-design-reviews/
The issue is fitting here today, in our discussion of “closure”
terminology recently, as well the jargons “lisp 1 vs lisp2” (multi-
meaning space vs single-meaning space), “tail recursion”, “currying”,
“lambda”, that perennially crop up here and elsewhere in computer
language forums in wild misunderstanding and brouhaha.
|
| Show full article (5.43Kb) |
|
28 Comments |
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: May 7, 2008 12:03
This is an excerpt from the latest version perlfaq3.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
3.25: Where can I learn about CGI or Web programming in Perl?
For modules, get the CGI or LWP modules from CPAN. For textbooks, see
the two especially dedicated to web stuff in the question on books. For
problems and questions related to the web, like "Why do I get 500
Errors" or "Why doesn't it run from the browser right when it runs fine
on the command line", see the troubleshooting guides and references in
perlfaq9 or in the CGI MetaFAQ:
http://www.perl.org/CGI_MetaFAQ.html
--------------------------------------------------------------------
|
| Show full article (1.49Kb) |
|
no comments
|
|
  |
Author: amirovicamirovic
Date: May 7, 2008 11:08
Hi,
I got two simple question where I don't know the answer and would
appreciate any help.
1) my $sting = "afdsf,sdgj,sdgjkgd,"
How can I find out how many commas are in this string. I think that
there should be a very simple perl solution to this without find it
out in a very wild way.
2) my $no = 0.00001;
print $no; // Output 1e-05
How can get 0.00001 and not an e-number?
Thanks for your help.
Regards,
Amir
|
| |
|
3 Comments |
|
  |
Author: hendedavhendedav
Date: May 7, 2008 08:01
Gang,
I am trying to use Net::SMTP to send email from a computer and it
fails to send (debug info below). I can take this same script and put
it on another computer and it works just fine. That would tell me
some piece of software isn't installed on the non-working computer,
but I have no idea as to what it may be. I have made sure the files
are the same on both computers that are listed in the "use" statements
at the top of the Net::SMTP module. I am using Debian 3.1 on the one
that works and 4.0 on the one that doesn't work. Any help would
greatly be appreciated.
Thanks,
Dave
|
| Show full article (1.13Kb) |
|
12 Comments |
|
  |
Author: cartercccartercc
Date: May 7, 2008 06:29
Please excuse this OT post.
I have had the experience of attempting to implement some wireless
routing protocols (GPSR and AODV) in Java in the past two years, and
the experience hasn't been particularly fulfilling. The ideas are good
but the technology, Java, leaves something to be desired.
Having some spare time, I picked up Joe Armstrong's book 'Programming
Erlang' and have been going through it. When I got to the sections on
concurrent programming, I felt that the floor just dropped from under
me. Having done some significant network programming in Java, I was
rendered breathless at the ease at which the same thing can be done in
Erlang.
Out of curiosity, I checked the job boards (Dice, etc.) for Erlang
jobs, and there seemed to be precious few. Erlang dates from the same
generation as Perl (mid 80s), and has strengths in concurrent,
distributed, and multi-processor programming. It also had an
impressive framework in the OTP.
|
| Show full article (1.36Kb) |
|
4 Comments |
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: May 7, 2008 06:03
This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
4.28: How do I change the Nth occurrence of something?
You have to keep track of N yourself. For example, let's say you want to
change the fifth occurrence of "whoever" or "whomever" into "whosoever"
or "whomsoever", case insensitively. These all assume that $_ contains
the string to be altered.
$count = 0;
s{((whom?)ever)}{
++$count == 5 # is it the 5th?
? "${2}soever" # yes, swap
: $1 # renege and leave it there
}ige;
In the more general case, you can use the "/g" modifier in a "while"
loop, keeping count of matches.
|
| Show full article (2.12Kb) |
|
no comments
|
|
  |
|
  |
Author: RonnyRonny
Date: May 7, 2008 03:31
I would like to install CPAN modules with the cpan command. Since I
don't have
write permission to the Perl installation directories, I need to do a
local installation.
After playing around with the cpan command a bit and looking at the
source code of
CPAN::Config, I created a $HOME/.cpan/CPAN/MyConfig.pm with the
following content:
$CPAN::Config->{cpan_home}="$ENV{HOME}/.cpan";
$CPAN::Config->{keep_source_where}=$CPAN::Config->{cpan_home}.'/
sources';
$CPAN::Config->{histfile}=$CPAN::Config->{cpan_home}.'/history';
$CPAN::Config->{build_dir}=$CPAN::Config->{cpan_home}.'/build';
This works fine for download and test, but install still tries to
write the modules into
the Perl installation directory. In addition, I get during install the
error message
sh: /Perl/cpan-autoconfig: not found
What is broken here?
|
| Show full article (0.84Kb) |
|
2 Comments |
|
|
|
|