comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
May 2008
motuwethfrsasuw
   1234 18
567891011 19
12131415161718 20
19202122232425 21
262728293031  22
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Why reading the FAQs is good (example)         


Author:
Date: May 25, 2008 19:10

So I was commenting some code I wrote for a friend who's new to perl and
I came across the following in my code:

# replace decimals with 999999999 in order to check for non-numerical
# data, then switch it back (this is a lazyman's shortcut)

$in{hours} =~ s/\./999999999/;
if ($in{hours} =~ /\D/) {
push @missing,'Hours contains non-numerical data';
$missing = 1;
}
$in{hours}=~s/999999999/\./;

And I realized I've been too lazy with this for too long. So my first
thought was to post here with "how do I test for non-numerical in decimal
number data?" but, of course, that violates the "How to ask intelligent
questions in CPLM", so I googled it.

Came up with a bunch of non-relevant results until I saw a similar
question and the answer was "Your answer is in perldoc perldata"

So I did exactly that. Of course, the answer *is* right there:

warn "not a decimal number" unless /^-?\d+\.?\d*$/;
Show full article (2.37Kb)
24 Comments
  FAQ 5.11 How can I write() into a string?         


Author: PerlFAQ Server
Date: May 25, 2008 18:03

This is an excerpt from the latest version perlfaq5.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 .

--------------------------------------------------------------------

5.11: How can I write() into a string?

See "Accessing Formatting Internals" in perlform for an "swrite()"
function.

--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
no comments
  blogs, longbets.org, and education of sociology         


Author: xahlee
Date: May 25, 2008 16:25

For about the past 10 years, i have been concerned in the programing
community's level of education in social issues.

I have found that recently, a news that would be of interest to
programers.

There was a bet at longbets.org (run by Long Now Foundation) regarding
the importance of blogs. The bet was made in 2002. The prediction has
a resolution date in 2007.

In 2008, the bet is resolved. See

“Decision: Blogs vs. New York Times” (2008-02-01) by Alexander Rose
http://blog.longnow.org/2008/02/01/decision-blogs-vs-new-york-times/

I'd like encourage, for many of you, who have lots of opinions on
technical issues or social issues surrounding software, to make use of
longbets.org. It can help shape your thoughts from blog fart to
something more refined. In any case, your money will benefit society.

here's some examples you could try:

• I bet that Java will be out of the top 10 programing languages by
2020.
Show full article (5.54Kb)
5 Comments
  FAQ 4.60 How can I always keep my hash sorted?         


Author: PerlFAQ Server
Date: May 25, 2008 12: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.60: How can I always keep my hash sorted?

You can look into using the "DB_File" module and "tie()" using the
$DB_BTREE hash bindings as documented in "In Memory Databases" in
DB_File. The "Tie::IxHash" module from CPAN might also be instructive.
Although this does keep your hash sorted, you might not like the slow
down you suffer from the tie interface. Are you sure you need to do
this? :)

--------------------------------------------------------------------
Show full article (1.39Kb)
no comments
  LWP::Parallel concerns         


Author: chadda
Date: May 25, 2008 10:21

Maybe I'm wrong, but if I were to use LWP::Parallel to parse a remote
site for a few hours, then couldn't this be possibly interpreted as a
Denial of Service? And if could be interpreted as a possibly Denial of
Service attack, what could I do to possibly avoid it?
3 Comments
  FAQ 7.4 How do I skip some return values?         


Author: PerlFAQ Server
Date: May 25, 2008 06:03

This is an excerpt from the latest version perlfaq7.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 .

--------------------------------------------------------------------

7.4: How do I skip some return values?

One way is to treat the return values as a list and index into it:

$dir = (getpwnam($user))[7];

Another way is to use undef as an element on the left-hand-side:

($dev, $ino, undef, undef, $uid, $gid) = stat($file);

You can also use a list slice to select only the elements that you need:

($dev, $ino, $uid, $gid) = ( stat($file) )[0,1,4,5];

--------------------------------------------------------------------
Show full article (1.41Kb)
no comments
  FAQ 4.62 Why don't my tied hashes make the defined/exists distinction?         


Author: PerlFAQ Server
Date: May 25, 2008 00: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.62: Why don't my tied hashes make the defined/exists distinction?

This depends on the tied hash's implementation of EXISTS(). For example,
there isn't the concept of undef with hashes that are tied to DBM*
files. It also means that exists() and defined() do the same thing with
a DBM* file, and what they end up doing is not what they do with
ordinary hashes.

--------------------------------------------------------------------
Show full article (1.35Kb)
no comments