[13529] in Perl-Users-Digest
Perl-Users Digest, Issue: 939 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 29 02:17:19 1999
Date: Tue, 28 Sep 1999 23:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938585417-v9-i939@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Sep 1999 Volume: 9 Number: 939
Today's topics:
Re: Sorting weird numeric data <uri@sysarch.com>
Re: Sorting weird numeric data <uri@sysarch.com>
Re: Sorting weird numeric data (Abigail)
Re: Sorting weird numeric data (Abigail)
Re: Sorting weird numeric data <uri@sysarch.com>
Re: Suggestion - comp.lang.perl.flame (was Re: You shou (Abigail)
Re: UNIX (Solaris 2.6) to NT ACCESS DB? <ccarr@websocket.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Sep 1999 00:29:50 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sorting weird numeric data
Message-Id: <x7hfkexrup.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> Benchmark: timing 16384 iterations of Abigail, Packed...
LR> Abigail: 43 wallclock secs (43.11 usr + 0.00 sys = 43.11 CPU)
LR> Packed: 15 wallclock secs (14.62 usr + 0.00 sys = 14.62 CPU)
i just knew you would nail this benchmark. and the GRP (fair name for
now) is much simpler code as well.
LR> sub Abigail {
LR> my @sorted = map {join "." => @$_}
LR> sort {my $i = 0;
LR> {defined $a -> [$i] or return defined $b -> [$i] ?
LR> -1 : 0;
LR> defined $b -> [$i] or return 1;
LR> $a -> [$i] <=> $b -> [$i] or ++ $i && redo}}
LR> map {[split /\./ => $_]}
LR> @unsorted;
LR> }
doing real work in the sort sub is not fun for the cpu. abigail should
know that but i think she just liked this as an interesting solution and
not as a fast one.
LR> sub Packed {
LR> my @sorted = map substr($_, 5) =>
LR> sort
LR> map pack('C5' => split /\./) . $_ => @unsorted;
LR> }
looks better and better. if we can only get this to be an idiom. but
then again, even the ST is not as well know as it should be. look at how
many newbies (and beyond) get overwhelmed by map sort map (either ST or
GRP). they just don't have enough lisp background. :-)
i have to get back to work on my module. it has been languishing far too
long. i am clearing up some projects and i may have some tuits over
yonder horizon.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 29 Sep 1999 00:48:26 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sorting weird numeric data
Message-Id: <x7emfixqzp.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> 'GR Sort' would be OK. I thought about 'SSS' (Super String Sort) also.
LR> I agree that we could use help here.
i don't wanna go near quantum physics and unified theories. out sort
might get sucked into a black/worm hole and never return.
>> this also assumes (probably correctly) tha 1.2 sorts before 1.2.1 but
>> does it sort before 1.2.0? the problem space needs to be defined more
>> clearly.
LR> Shorter should sort first.
it just has to be defined. it doesn't matter which order you want as
long as you keep it consistant.
LR> That packs nonexistent trailing values in the list from 'split' into
LR> null bytes. This is exactly what is wanted, but I don't know why '-w'
LR> doesn't complain. It also restricts the number of fields in the input
LR> to a maximum of 5. (But that can be raised arbitrarily without slowing
LR> the sort unduly.)
well, we have previously seen my preference for fixed widths and yours
for variable widths. this is just another place it shows up.
LR> Note that having done that, one no longer needs the null byte to
LR> separate the sortkey from the data, and can replace the 'rindex' stuff
LR> by simply "substr($_, 5)".
LR> print map substr($_, 5) =>
LR> sort
LR> map pack('C5' => split /\./) . $_ =>
LR> <DATA>;
LR> __END__
good point. that is one advantage of fixed sort key widths. i forgot to
fix that when i made the width fixed.
LR> I had in mind a rather neat article posted by Abigail last week, that
LR> showed how to write a laddered sortsub for arbitrarily long signed
LR> floating-point strings. But a prepass would be required to compute the
LR> appropriate sortkey length for a packed sort. Here's one that just
LR> takes an arbitrary maximum length:
this reminds me to tell you i was thinking about how to preprocess a
float string to packed sortable. here i what i have thought about so
far.
the first char is a sign char. just pick something where what represents
+ will sort after the - substitute. then sprintf the floats with %e
(scientific notation). the exponent is zero padded and its sign char is
also converted like the sign of the whole value. positive exponent signs
are greater than negative. then the exponent is packed padded to a
fixed number of digits (2 or 3). for positive exponents, this works
fine. for negative expoenents, do some inversion like subtracting from
100 or 1000. since the sign of the exponent is compared first, only
floats with similar exponent signs will get compared in this phase.
finally the normalized mantissa (from the sprintf %e) is packed (padded
if desired).
i haven't gone over this with a fine toothed comb but is seems to work
on paper. lots of crunching but it is portable. but as most cpu's have
ieee floats which sort properly in binary, this may not be needed. or it
could be an option in the module.
LR> A final note: If all that is being sorted is the list of numbers (a
LR> poor assumption), then appending the entire datum to the sortkey isn't
LR> required. The input can be reconstructed from the sortkey very
LR> straightforwardly.
true, but getting the original key off the end is usually simpler and
faster so why decode the records from the keys.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 29 Sep 1999 00:25:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Sorting weird numeric data
Message-Id: <slrn7v3959.a6f.abigail@alexandra.delanet.com>
Larry Rosler (lr@hpl.hp.com) wrote on MMCCXX September MCMXCIII in
<URL:news:MPG.125b0e6868abb18f989ff8@nntp.hpl.hp.com>:
<>
<> sub Packed {
<> my @sorted = map substr($_, 5) =>
^
|
Does this mean your solution
has arbitrary limits?
<> sort
<> map pack('C5' => split /\./) . $_ => @unsorted;
<> }
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 29 Sep 1999 00:29:28 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Sorting weird numeric data
Message-Id: <slrn7v39c3.a6f.abigail@alexandra.delanet.com>
Uri Guttman (uri@sysarch.com) wrote on MMCCXX September MCMXCIII in
<URL:news:x7hfkexrup.fsf@home.sysarch.com>:
$$ >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
$$
$$
$$ LR> Benchmark: timing 16384 iterations of Abigail, Packed...
$$ LR> Abigail: 43 wallclock secs (43.11 usr + 0.00 sys = 43.11 CPU)
$$ LR> Packed: 15 wallclock secs (14.62 usr + 0.00 sys = 14.62 CPU)
$$
$$ i just knew you would nail this benchmark. and the GRP (fair name for
$$ now) is much simpler code as well.
Simpler? I've never seen any code that use pack that I find simple.
After years of using Perl, I still need to manual and 47 tries to get
it right when using pack/unpack.
The code below is trivial, and requires no thinking when writing down.
$$ LR> sub Abigail {
$$ LR> my @sorted = map {join "." => @$_}
$$ LR> sort {my $i = 0;
$$ LR> {defined $a -> [$i] or return defined $b -> [$i] ?
$$ LR> -1 : 0;
$$ LR> defined $b -> [$i] or return 1;
$$ LR> $a -> [$i] <=> $b -> [$i] or ++ $i && redo}}
$$ LR> map {[split /\./ => $_]}
$$ LR> @unsorted;
$$ LR> }
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 29 Sep 1999 02:01:30 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sorting weird numeric data
Message-Id: <x7670uxnlx.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@delanet.com> writes:
A> Uri Guttman (uri@sysarch.com) wrote on MMCCXX September MCMXCIII in
A> $$ i just knew you would nail this benchmark. and the GRP (fair name for
A> $$ now) is much simpler code as well.
A> Simpler? I've never seen any code that use pack that I find simple.
A> After years of using Perl, I still need to manual and 47 tries to get
A> it right when using pack/unpack.
A> The code below is trivial, and requires no thinking when writing down.
oh balderdash! i could read larry's GRP sort in seconds while i had to
really parse your code and find the hidden loop made by redo. talk about
a rarely used operator. so to each their own. once you use pack a
little, most of the field names are easy to remember. i don't know them
all by heart but C, N, H, A are burned in my brain. and the rest are
only a perldoc away. do you know all the options to printf? i still
check on some, so this is no different. i am amazed you look down on
such a powerful and useful operator like pack.
true, complex lists of pack fields can be confusing but this uses just
C5 which is 5 unsigned chars. pretty easy to figure out. and it should
be commented anyway. also i think there is a pack field comment syntax
being worked on by ilya for 5.6 or beyond.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 29 Sep 1999 00:43:35 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Suggestion - comp.lang.perl.flame (was Re: You should be admired)
Message-Id: <slrn7v3a6l.a6f.abigail@alexandra.delanet.com>
Matthew O. Persico (mpersico@erols.com) wrote on MMCCXX September
MCMXCIII in <URL:news:37F1662F.F30801C2@erols.com>:
~~ Abigail wrote:
~~
~~ > No. There's already a CGI group, and people don't post there. What makes
~~ > you think that another CGI group would solve the problem?
~~
~~ I think the key is that 'perl' and 'cgi' must be in the name together.
~~ There are plenty of cgi groups, true. But the posts we get are perl/cgi
~~ queries.
No. The problem are questions that are 100% CGI questions. The fact that
the language being used to implement those programs in Perl is a red
herring.
~~ Now, on my ISP's server, a quick look for newsgroups with cgi in them
~~ reveals about 10 of them. Of those, the only ones with 'perl' in the names
~~ are
~~
~~ alt.comp.perlcgi.freelance
~~ de.comp.lang.perl.cgi
~~
~~ The 'main' group appears to be
~~
~~ comp.infosystems.www.authoring.cgi
Of course. Probably predates comp.lang.perl.misc (although not by much).
~~ None of these (to me anyway) is what I consider obvious enough for a newbie
~~ to stumble across. So what does s/he do next? Turns to the B<language> that
~~ is being used to implement cgi and that leads them straight to
~~ comp.lang.perl.misc.
And? Just because newbies can't find the obvious group, a new group in
the wrong hierarchie should be created? That's stupid.
~~ That's my reasoning for thinking that comp.lang.perl.cgi would siphon off a
~~ good deal of the noise in clp.misc. You have to stop thinking B<reasonably>
~~ here and put yourself in the place of a hapless programmer who has grown up
~~ on CS courses with no hardware training, learned his skills from a
~~ correspondance course or a "For Dummies" book and simply has not had the
~~ training in scholarship that would lead to the asking of a question to be
~~ the B<last> resort instead of the first.
I've no sympathy for those people. Finding the right group in the big-8
isn't exactly rocket science.
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 28 Sep 1999 23:37:32 -0500
From: Clinton Carr <ccarr@websocket.com>
To: George Plumfield <GPlumfield@worldnet.att.net>
Subject: Re: UNIX (Solaris 2.6) to NT ACCESS DB?
Message-Id: <37F1978B.81F134C@websocket.com>
I have two different but somewhat similar solutions.
One is my IDBS and the other is based on ASP. IDBS is installed on a NT server
that has access to a '*.mdb' database. It connects to the MS Access
database via Microsoft's ODBC driver and then listens for incoming
SQL requests via a socket connection. When a request is received it
processes it and sends back the answer set using the socket connection.
The IDBS package includes a perl object (IDBS.pm) that handles the details of
sockets communication and data passing. IDBS is a multithreaded
application and is quite fast. Below is a snippet of perl code that
runs on the web server, be it UNIX or NT.
# Import the IDBS perl module
#
use IDBS;
# Create an IDBS object using the name or ip address and
# port number of the IDBS data server
#
my $q = IDBS->new('db.ntserver.com', 2312);
# Issue the SQL command
#
$q->command("select * from tblCustomer");
if ($q->{CODE} == 0) {
#
# Display the record count
#
my $tmp = $q->getrecordcnt;
print "The number of rows returned is: $tmp\n";
#
# Display the column count
#
$tmp = $q->getcolumncnt;
print "The number of columns per row is: $tmp\n";
#
# Display the column headings
#
$q->gethdrs;
my $hdata = $q->getfirstcol;
while ($q->{CODE} < 1) {
print "Column heading is: $hdata\n";
$hdata = $q->getnextcol;
}
#
# Display the column data
#
$q->getfirstrow;
while ($q->{CODE} < 1) {
$cdata = $q->getfirstcol;
while ($q->{CODE} < 1) {
print "Column data is: $cdata\n";
$cdata = $q->getnextcol;
}
$q->{CODE} = 0;
$q->getnextrow;
}
} else {
#
# Display the error code and message
#
print "This is the error code and message: $q->{CODE}/$q->{MESG}\n";
}
The second option is basically the same as the first except that IDBS is
replaced by an ASP page. The page is invoke as a URL reference. However,
the perl interface comforms to the same style and commands as described above.
This solution works fine too, except it requires ASP and it is not as fast as
my IDBS.
Hope this helps.
Clinton
George Plumfield wrote:
> I'll be Perl-processing some files on a UNIX-Solaris 2.6 machine and would
> like to directly update an Access DB (.mdb) residing on a NT machine
> (intranet and NFS Maestro access to the NT filesystem).
>
> Is this possible? If so, hi-level how?
>
> The alternative is to copy the files over to NT and then run through DBI,
> DBD::ADO, but I would love to do it directly from UNIX.
>
> Thanks for any help!
>
> George Plumfield
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 939
*************************************