[26257] in Perl-Users-Digest
Perl-Users Digest, Issue: 8441 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 21 18:05:50 2005
Date: Wed, 21 Sep 2005 15:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 21 Sep 2005 Volume: 10 Number: 8441
Today's topics:
*fastest* was to get a large directory listing in Perl <brundlefly76@hotmail.com>
Integer conversion and back again <cpryce@nospam.pryce.net>
Using CPAN.pm with multiple perl installs <brundlefly76@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Sep 2005 14:57:55 -0700
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: *fastest* was to get a large directory listing in Perl
Message-Id: <Y9adnSgxcfb5SqzeRVn-jA@comcast.com>
There are several methods of getting a large directory listing (3000+ files
in a single directory) in Perl, but all the methods I've tried (<*>,
readdir) are vastly slower in my usage then using readdir in C.
This doesnt seem to make sense, since I imagine perl is just making the same
system call.
Opinions appreciated...
------------------------------
Date: Wed, 21 Sep 2005 16:53:30 -0500
From: cp <cpryce@nospam.pryce.net>
Subject: Integer conversion and back again
Message-Id: <210920051653306130%cpryce@nospam.pryce.net>
I have a database field to hold a string that is represented as a
series of digits separated by dashes. The string will be input by a
user. The format of the string is 1-3 digits followed by a three digit
sequence, follow by a three digit sequence.
Users being what they are, many are dropping the leading zeros in the
middle and end set. I need to treat the user input of 060-090-014 the
same as 60-090-14 and the same as 60-90-14.
My thought was to convert the string to an integer, and store it in the
database (in the example, as 60090014). Since the last three digits
represent the sequence in which the numbers where issued, that also
makes the strings easier to sort.
I adapted the add commas re from perl FAQ and came up with the
following code. I'd appreciate any other ideas. Error checking to make
sure that the number contains two dashes, etc. has been omitted.
Eventually the final three digits will go to four digits. Can I get a
suggestion for a solution that deals with that?
#!/usr/bin/perl
use strict;
use warnings;
my $n = $ARGV[0] || '60-090-14';
my $sp = pack_sp( $n );
print $sp, "\n";
# prints 60090014
print unpack_sp( $sp ), "\n";
# prints 60-090-014
sub pack_sp {
local $_ = shift;
my @sp = split/-/;
return int( sprintf("%3d%03d%03d", @sp ) );
}
sub unpack_sp {
local $_ = shift;
1 while s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1-/g;
return $_;
}
--
cp
------------------------------
Date: Wed, 21 Sep 2005 15:00:22 -0700
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Using CPAN.pm with multiple perl installs
Message-Id: <99KdnSMtUuZgSqzeRVn-jA@comcast.com>
Is there a way to use CPAN.pm with multiple Perl installs?
What are the issues one needs to look out for?
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8441
***************************************