[22739] in Perl-Users-Digest
Perl-Users Digest, Issue: 4960 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 9 00:06:42 2003
Date: Thu, 8 May 2003 21: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 Thu, 8 May 2003 Volume: 10 Number: 4960
Today's topics:
ActiveState Perlapp ERROR : Can't locate ..... with Net (Anand Ramamurthy)
Re: ActiveState Perlapp ERROR : Can't locate ..... with <bwalton@rochester.rr.com>
Bloody Java Proselytisers!!! <dodger@dodger.org>
Re: converting cgi scripts to java <igor@rat-farm.com>
Re: Hash memory consumption <mhunter@celeste.net.berkeley.edu>
Re: How do you create a biniary file in Perl. <bart.lateur@pandora.be>
Logic(al nightmare!) <sammie@greatergreen.com>
Re: More on flock().... <urael@zrgebcbyvf.arg.nh>
Re: More on flock().... (Tad McClellan)
Re: No ouput from Net::SSH:Win32Perl / Net::SSH::Perl (Quackie)
Re: Perl LWP and the https protocol <mooncm.lbkejwiAhEgSfSe@dAcEbSaS>
positioning the output <farmers@ihug.com.au>
Re: positioning the output (Tad McClellan)
regex to extract number <cfowler@linuxiceberg.com>
Re: regex to extract number <noreply@gunnar.cc>
Re: regex to extract number <krahnj@acm.org>
Re: Single-threaded, long-running network server? <cfowler@linuxiceberg.com>
Re: Sorting book list <emschwar@pobox.com>
Re: Sorting book list (Jay Tilton)
Re: Subtracting strings [long post] (Quantum Mechanic)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 May 2003 16:31:50 -0700
From: anand_ramamurthy@yahoo.com (Anand Ramamurthy)
Subject: ActiveState Perlapp ERROR : Can't locate ..... with Net::SSH::Perl
Message-Id: <761041e6.0305081531.5656c389@posting.google.com>
I use PerlApp 4.1.2.
I have a script that uses Net::SSH::W32Perl and Net::SSH::PERL.
When I run the script from command line (perl tst.pl) it works fine.
When I build a Windows executable using PerlApp and run the executable
I get error:
C:\SSH>tst
Can't locate Net/SSH/Perl/Util/Hosts.pm in @INC (@INC contains:
C:\SSH) at /PerlApp/Net/SSH/Perl/Util.pm line 56.
BEGIN failed--compilation aborted at /PerlApp/Net/SSH/Perl.pm line 11.
BEGIN failed--compilation aborted at /PerlApp/Net/SSH/W32Perl.pm line
8.
BEGIN failed--compilation aborted at tst.pl line 1.
The file c:\perl\site\lib\Net\SSH\Perl\Util\Hosts.pm exists.
Any/all help appreciated.
Regards,
-anand
anand_ramamurthy@yahoo.com
------------------------------
Date: Fri, 09 May 2003 00:19:03 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: ActiveState Perlapp ERROR : Can't locate ..... with Net::SSH::Perl
Message-Id: <3EBAF3D8.1080808@rochester.rr.com>
Anand Ramamurthy wrote:
> I use PerlApp 4.1.2.
>
> I have a script that uses Net::SSH::W32Perl and Net::SSH::PERL.
>
> When I run the script from command line (perl tst.pl) it works fine.
>
> When I build a Windows executable using PerlApp and run the executable
> I get error:
>
> C:\SSH>tst
> Can't locate Net/SSH/Perl/Util/Hosts.pm in @INC (@INC contains:
> C:\SSH) at /PerlApp/Net/SSH/Perl/Util.pm line 56.
--^^^^^^
@INC does not include C:\perl\site\lib, which is
where you say (below) the hierarchy to
Net::SSH::Perl::Util::Hosts.pm is located. Try
adding that path to @INC and see if it works better.
...
> The file c:\perl\site\lib\Net\SSH\Perl\Util\Hosts.pm exists.
...
> -anand
--
Bob Walton
------------------------------
Date: Thu, 08 May 2003 21:35:06 -0500
From: Dodger <dodger@dodger.org>
Subject: Bloody Java Proselytisers!!!
Message-Id: <Xns9375C791494DDdodgerdodgerorg@216.166.71.239>
Okay, social issue here...
Why is it that every time I start on a project in Perl some dumbass has to
pipe up with why he thinks I should do it in Java instead?
I'm working on a Perl module that reads in and parses CuriousLabs' Poser
documents and allows manipulation and creation of same.
It's a Perl module.
A PERL Module.
Yet when I posted about it on Renderosity.com (the Poser community's home,
pretty much) someone inevitably replied to my forum post with why Java
would, in his humble (cough) opinion, be a better approach.
YEAH. Java is always a better way to write PERL MODULES.
*tears out hair*
I love Perl. I love Perl programming. I love writing Perl code and figuring
out how to do things somene else said was hard or impossible.
As a matter of fact, I think the only thing about being a JAPH that I don't
like is putting up with the bloody Java proselytisers who seem to think
that *everything* should be done in Java and Java is always a better
approach.
*sigh*
If you want the pre-release version fo the module which currently only
reads Poser docs into a Perl datastructure, go to
http://www.dodger.org/ttt/poserParser/PoserParser.pm -- I'll try to keep
that web-accessible copy up-to-date.
--
Dodger
------------------------------
Date: Thu, 08 May 2003 21:38:48 -0500
From: Igor <igor@rat-farm.com>
Subject: Re: converting cgi scripts to java
Message-Id: <Xns9375C831DE3BBigorratfarmcom@216.166.71.239>
anekwe <member@dbforums.com> wrote in news:2021470.1036694561@dbforums.com:
>
> looking for instructions on how to completely convert a perl cgi to java
>
> --
> Posted via http://dbforums.com
1: Change mind
2: run Perl CGI instead
3: disable your Java engine
4: Don't say naughty words* in Perl fora.
* like 'Java' (unless you mean a Slammahamma from Coffee People, an island,
or bones dug up by the Leakeys)
------------------------------
Date: Thu, 8 May 2003 23:49:41 +0000 (UTC)
From: Mike Hunter <mhunter@celeste.net.berkeley.edu>
Subject: Re: Hash memory consumption
Message-Id: <slrnbblr5t.18l.mhunter@celeste.net.berkeley.edu>
On 08 May 2003 15:34:33 GMT, ctcgag@hotmail.com wrote:
> It could be, but the only way to know is to get good numbers. Large
> hashes contain large numbers of scalars, and scalars are often pretty
> memory inefficient.
I instrumented the script with BSD::Resource...I didn't spend enough time
with it, but I did confirm to myself that "yep, it grows quite a bit with
each addition".
> > > Large hashes are pretty memory efficient, at least for general purpose
> > > use. If you're use for the hash is not general purpose, I'd have to
> > > know what is non-general about your purpose before suggesting ways to
> > > improve it.
> >
> > Basically I have
> >
> > while (<HUGEDATA>)
> > {
> > my ($source, $dest, $d1,$d2,$d3,$d4,$d5) = split...;
> > $hash{$source}->{$dest} += [$d1,$d2,$d3,$d4...];
> > }
> >
> > Of course with lots more code to make that actually work.
>
> That += can't do anything good to your arrayref, so I assume
> that's not actually what you do.
Correct. I have a sub-routine to do what I want.
Off topic: Is there a good way to get += for a vector using map or some
other perl magic?
> How many distinct $source values are there? You have that number
> of hashes, plus the one master hash. Each hash has ~80 bytes of overhead,
> which is insignificant for a huge hash (because it's spread over thousands
> of entries), but that ~80 bytes each adds up when there are 100,000 hashes
> with only 2 entries each.
Thanks for the numbers. There are > 10*65536* possible $source
strings, but likely not more than 10*100.
> How many $dest values are there for each $source?
Potentially thousands, but more likely dozens.
> In addition to ~80 bytes
> overhead, each hash entry requires about 12-16 bytes overhead (i.e. 12-16
> bytes more than it would take to store the key and value in an array),
> unless the key is already key in another hash, then it's just 12-16 bytes
> more than the value takes.
Also good to know; thanks.
> However, there isn't much you can do about all this, besides making
> fewer hashes or fewer hash entries. Really, you need the numbers,
> once you have those you can model the system to see where the
> memory is going.
I'm hoping to clean it up and put it out on the web, but right now it's
too intertwined with system-specific stuff.
> If I were in your shoes, I would go a different route:
>
> 1a) Use a system sort method to sort huge_data by source and target,
> then just process it in a single pass without having to store
> everything in memory (It seems you are only hashes for grouping
> so this should be possible).
I'll think about that.
> 1b) or, run the program N times, computing a checksum%N on source and
> processing a different result set each time.
:)
> 2) and then, I'd look into whatever is generating the huge file, to
> see if it can't do it in a better way.
2 is pretty well fixed. It's netflow data from a router.
Thanks very much for your suggestions.
Mike
------------------------------
Date: Thu, 08 May 2003 22:54:37 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <6snlbvodlo6627spvc6mpcuh3n8a2nglk4@4ax.com>
Michael Carman wrote:
>Hmm. I would expect \r to be reliable, yet perlport claims that it's a
>LF on Mac. Is there anyone with a Mac able to confirm or refute this?
Yup.
The thing is: the character (combination) for line ends, is chr(13), on,
the Mac. Matthias Neeracher, who originally ported perl to MAcPerl,
decided to represent this with "\n", thus "\n" eq chr(13).
Would it make sense to make "\r" equal to chr(13) as well? Not really...
So in the end, the physical meaning of "\r" and "\n" got reversed, but
not its logical value: "\n" is logical line end, "\r" is "the other
one".
--
Bart.
------------------------------
Date: Fri, 09 May 2003 03:42:34 GMT
From: "Brad Walton" <sammie@greatergreen.com>
Subject: Logic(al nightmare!)
Message-Id: <KsFua.784691$F1.99265@sccrnsc04>
I have a logic issue, and I am fairly new to perl, so the use of FOR,
FOREACH, WHILE are still in my learning stages. I am trying to read a file,
look for matches, and if found, read another file for its match and replace
the info. I am use Tie::File to edit the line.
Here is my code:
----
sub file_stats_left {
$n = 0;
$o = 0;
$p = 0;
$q = 0;
$r = 0;
tie @DB, 'Tie::File', $dormantstatdb or "cannot open $dormantstatdb: $!
\n";
for (@DB) {
my ($type,$name,@rest) = split /\t/, $DB[$n];
for (@discpl) {
if ($discpl[$o] eq $name) {
for (@oldsession) {
my ($oldtype,$thisname,@thisrest) = split /\t/, $oldsession[$p];
if ($thisname eq $discpl[$o]){
$DB[$n] = $oldsession[$p];
$added{$thisname} = 1;
}
$p++;
}
}
$o++;
}
$n++;
}
for (@discpl) {
for (@oldsession) {
my ($thistype,$thisname,@thisrest) = split /\t/, $oldsession[$r];
if ($thisname eq $discpl[$q]){
if(!$added{$thisname}){
push @DB, @oldsession[$r];
}
}
$r++;
}
$q++;
}
untie @DB;
}
----
The first part replaces info if found, the second part adds if not found.
What I am 'trying' to do in the first half is open the database, and grab
$name from each line. Each time I grab $name, I want to bash it against the
@discpl (which means disconnected players) to determine if there is a match.
If there is, I want to further bash it against the previous array which
contained the disconnected players final information.
What I get now is incorrect output, due to incorrect use of FOR and probably
some bad logic.
Any help is appreciated,
Brad
------------------------------
Date: Fri, 09 May 2003 11:23:22 +0930
From: Henry <urael@zrgebcbyvf.arg.nh>
Subject: Re: More on flock()....
Message-Id: <urael-969A7C.11232209052003@nswpull.telstra.net>
In article <b9dlbr$45p$1@nets3.rz.RWTH-Aachen.DE>,
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote:
> > Let's say I want to write to a file, clobbering whatever was in it, but
> > only if I can get an exclusive lock on the file.
> >
> > Would the way to do this be to open it with mode "+<", ask for a non-
> > binding exclusive lock, and then go ahead if I get the lock, or close
> > the filehandle and forget about it if I don't?
>
> Probably, yes. If your system has nonblocking locks, you can do it
> thusly:
>
> use Fcntl qw/:flock/;
>
> open F, "+<", "file" or die $!;
> if (flock F, LOCK_EX|LOCK_NB) {
> # got the lock so write into file
> ...
> }
Hmmm... Excuse me for interrupting, folks, but doesn't "+<" indicate
that you want to _read_and_write_ the file... with writes going to the
end of the file? It won't clobber the file.
What you probably want is:
open(F, ">$file");
or
open(F, "+>$file");
Henry.
------------------------------
Date: Thu, 8 May 2003 22:43:59 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: More on flock()....
Message-Id: <slrnbbm8vv.1mh.tadmc@magna.augustmail.com>
Henry <urael@zrgebcbyvf.arg.nh> wrote:
> In article <b9dlbr$45p$1@nets3.rz.RWTH-Aachen.DE>,
> "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote:
>
>> > Let's say I want to write to a file, clobbering whatever was in it, but
>> > only if I can get an exclusive lock on the file.
>> open F, "+<", "file" or die $!;
>> if (flock F, LOCK_EX|LOCK_NB) {
>> # got the lock so write into file
> Hmmm... Excuse me for interrupting, folks, but doesn't "+<" indicate
> that you want to _read_and_write_ the file...
Yes.
> with writes going to the
> end of the file?
No. Writes go wherever the handle's file pointer is pointing to.
> It won't clobber the file.
You can make it clobber the file:
perldoc -f truncate
perldoc -f seek
> What you probably want is:
to always, yes *always*, check the return value from open().
> open(F, ">$file");
> or
> open(F, "+>$file");
Read the part of the OP that starts with "but" :-)
Both of those will clobber file before a lock is even attempted.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 8 May 2003 17:52:37 -0700
From: minh_quoc@yahoo.com (Quackie)
Subject: Re: No ouput from Net::SSH:Win32Perl / Net::SSH::Perl
Message-Id: <39787a94.0305081652.48d1add5@posting.google.com>
Your command to send suppose to be like this:
($out, $err, $exit) = $ssh->cmd("uname", "-a");
REason: the "uname" is the name of command and "-a" is the $stdin or
arguments of the command. You have to separate those two. Try it
again.
anand_ramamurthy@yahoo.com (Anand Ramamurthy) wrote in message news:<761041e6.0305072035.6a9c7c48@posting.google.com>...
> I am using PERL versions: v5.6.1 & v5.8.0 on Windows machines.
>
> I am trying to use Net::SSH::Win32Perl to access a HP-UX m/c
> from a MS Win2K box.
>
> I realize by using Net::SSH::Win32Perl, I can use only SSH2
> protocols.
>
> After installing all dependencies, I was able to install all the
> required modules.
>
> Here's the test script I am trying:
> ----------------------------------- Begin --------------------------
> use Net::SSH::W32Perl;
>
> my $host="11.22.33.44";
> my $user="login";
> my $passwd="passwd";
>
> my ($ssh, $out, $err, $exit);
>
> my %args;
> $args{debug} = 1;
> $args{protocol} = 2;
>
> $ssh = new Net::SSH::W32Perl($host, %args);
> $ssh->login($user, $passwd);
>
> ($out, $err, $exit) = $ssh->cmd("uname -a");
>
> print "OUT: [$out]\n";
> print "ERR: [$err]\n";
> print "EXIT: [$exit]\n";
> ----------------------------------- End --------------------------
>
> The output on the screen:
> ----------------------------------- Begin --------------------------
> C:\SSH>perl xx.pl
> anandr: Reading configuration data /.ssh/config
> anandr: Reading configuration data /etc/ssh_config
> anandr: Connecting to 11.22.33.44, port 22.
> anandr: Socket created, turning on blocking...
> anandr: Remote protocol version 2.0, remote software version OpenSSH_3.5p1
> anandr: Net::SSH::Perl Version 1.23, protocol version 2.0.
> anandr: No compat match: OpenSSH_3.5p1.
> anandr: Connection established.
> anandr: Sent key-exchange init (KEXINIT), wait response.
> anandr: Algorithms, c->s: 3des-cbc hmac-sha1 none
> anandr: Algorithms, s->c: 3des-cbc hmac-sha1 none
> anandr: Entering Diffie-Hellman Group 1 key exchange.
> anandr: Sent DH public key, waiting for reply.
> anandr: Received host key, type 'ssh-dss'.
> anandr: Host '11.22.33.44' is known and matches the host key.
> anandr: Computing shared secret key.
> anandr: Verifying server signature.
> anandr: Waiting for NEWKEYS message.
> anandr: Enabling incoming encryption/MAC/compression.
> anandr: Send NEWKEYS, enable outgoing encryption/MAC/compression.
> anandr: Sending request for user-authentication service.
> anandr: Service accepted: ssh-userauth.
> anandr: Trying empty user-authentication request.
> anandr: Authentication methods that can continue: publickey,password,keyboard-in
> teractive.
> anandr: Next method to try is publickey.
> anandr: Next method to try is password.
> anandr: Trying password authentication.
> anandr: Login completed, opening dummy shell channel.
> anandr: channel 0: new [client-session]
> anandr: Requesting channel_open for channel 0.
> anandr: channel 0: open confirm rwindow 0 rmax 32768
> anandr: Got channel open confirmation, requesting shell.
> anandr: Requesting service shell on channel 0.
> anandr: channel 1: new [client-session]
> anandr: Requesting channel_open for channel 1.
> anandr: Entering interactive session.
> anandr: Sending command: uname -a
> anandr: Requesting service exec on channel 1.
> anandr: channel 1: open confirm rwindow 0 rmax 32768
> ----------------------------------- End --------------------------
>
> It just hangs here forever. No output.
>
> Any idea what may be wrong?
> Appreciate any/all help.
>
> Regards,
>
> -anand
> anand_ramamurthy@yahoo.com
------------------------------
Date: Fri, 09 May 2003 00:08:55 GMT
From: "BSK" <mooncm.lbkejwiAhEgSfSe@dAcEbSaS>
Subject: Re: Perl LWP and the https protocol
Message-Id: <rkCua.62303$ey1.5562304@newsread1.prod.itd.earthlink.net>
Thanks Mothra,
Do you have a pointer to the lwpcook document? Sounds interesting.
BSK
"Mothra" <mothra@nowhereatall.com> wrote in message
news:3eba9e1c$1@usenet.ugs.com...
>
> "BSK" <mooncm.lbkejwiAhEgSfSe@dAcEbSaS> wrote in message
> news:0Twua.61843$ey1.5526131@newsread1.prod.itd.earthlink.net...
> > Hello All,
> >
> > Does anyone know if there are secure https versions of the LWP GET and
> POST
> > functions available anywhere?
> >
> > Much thanks for your help.
> >
> >
> > BSK
> You need to take a look at the lwpcook document. Basically,
> you need the crypt-SSleay module to get the functionality you
> are looking for.
>
> Mothra
>
>
------------------------------
Date: Fri, 9 May 2003 10:43:36 +1000
From: "Hugo" <farmers@ihug.com.au>
Subject: positioning the output
Message-Id: <b9etjr$vnp$1@lust.ihug.co.nz>
Does anyone know how to set the output to be displayed on the screen with a
specific location ie. print the output at column 10 row 5
i know if under unix shell, its something like "tput cup 10 5"
pls help
^^
------------------------------
Date: Thu, 8 May 2003 22:49:57 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: positioning the output
Message-Id: <slrnbbm9b5.1mh.tadmc@magna.augustmail.com>
Hugo <farmers@ihug.com.au> wrote:
> Does anyone know how to set the output to be displayed on the screen with a
^^^^^^
^^^^^^
> specific location
perldoc -q screen
"How do I do fancy stuff with the keyboard/screen/mouse?"
and then
http://search.cpan.org/author/WPS/Curses-1.06/
> pls help
Please check the Perl FAQ more carefully before posting
to the Perl newsgroup.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 08 May 2003 18:12:45 -0400
From: Chris Fowler <cfowler@linuxiceberg.com>
Subject: regex to extract number
Message-Id: <1052431740.161075@minime.linuxiceberg.com>
Maybe someone can help me here. I have the following line I'm receving by a
remote syslog server
<38>login[72]: login exiting
I want to break it into 2 parts.
1) The numbe part.
2) The message after '>'
Can someone give me a regex that will extract that info?
Thanks,
Chris
------------------------------
Date: Fri, 09 May 2003 00:38:32 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: regex to extract number
Message-Id: <b9emm5$i7lge$1@ID-184292.news.dfncis.de>
Chris Fowler wrote:
> Maybe someone can help me here. I have the following line I'm
> receving by a remote syslog server
>
> <38>login[72]: login exiting
>
> I want to break it into 2 parts.
>
> 1) The numbe part. 2) The message after '>'
>
> Can someone give me a regex that will extract that info?
Yes, you can. It's a _very_ simple regex problem, and you should be
able to write it by studying about anything dealing with Perl regular
expressions. This is the Perl doc:
http://www.perldoc.com/perl5.8.0/pod/perlre.html
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 08 May 2003 22:46:02 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: regex to extract number
Message-Id: <3EBADE09.84E2DF1F@acm.org>
Chris Fowler wrote:
>
> Maybe someone can help me here. I have the following line I'm receving by a
> remote syslog server
>
> <38>login[72]: login exiting
>
> I want to break it into 2 parts.
>
> 1) The numbe part.
> 2) The message after '>'
>
> Can someone give me a regex that will extract that info?
my ( $number, $message ) = $line =~ /<(\d+)>(.+)/;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 08 May 2003 18:17:51 -0400
From: Chris Fowler <cfowler@linuxiceberg.com>
Subject: Re: Single-threaded, long-running network server?
Message-Id: <1052432046.255603@minime.linuxiceberg.com>
You could timeout in your select() and then process what you need to
do if a time interval has passed. But, this will tie up your program
and network connections will not be accept()ed.
I hate to say it, but I would do one of 2 things
1) use Thread
2) Use IPC and shared memory. Store all your data in
shared memory and allow another perl program to process
that data. Just remeber to use some form of locking
likc semaphores.
Michael L. Artz wrote:
> I am having a little design problem that I can't seem to wrap my head
> aronud. I have an existing long running and processor intensive perl
> script that I would like to modify to take commands from a network
> socket. The script needs to be run single-threaded (i.e. no forking and
> only one process can/should be running) due to synchronization issues.
>
> My first thought was to just wrap a standard "listen, bind, select,
> accept" loop around the computation, however at some point I need to run
> the parts of the script that take a long time, and figured that I would
> be dropping connections if too many queued up over the network.
>
> I next thought of two other solutions: either (a) use an old-school IPC
> shared variable to share data between the network server (which would
> accept connections and add commands to the shared var) and the
> long-running script (which would read/delete commands from the shared
> var), or (b) have the server open a pipe to the long running process
> (i.e. open LONGPIPE, "| myscript.pl") and modify the long running script
> to do a select over STDIN.
>
> I am sure that there is some existing idiom for this sort of work, but I
> can't seem to find it, and thought that I would ask around a little
> before I went and tried to code something that "works".
>
> Any help would be appreciated.
>
> Thanks
> -Mike
------------------------------
Date: 08 May 2003 17:55:22 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Sorting book list
Message-Id: <etowuh1uh79.fsf@wormtongue.emschwar>
Gopi Sundaram <gopalan@cs.sc.edu> writes:
> On Thu, 8 May 2003, Bill Smith wrote:
>
> > @array = sort {a->'author' cmp b->'author' or a->'series' <=>
> > b->'series'} @array;
>
> An author may have multiple series'. The 'series' key contains
> "SeriesName seq_no", for example, "ArabianNights 1".
>
> So the series sequence number should only be considered if $a and $b are
> part of the same series.
At this point I feel compelled to point out Net::Z3950 and
MARC::Record. I don't think Net::Z3950 is in CPAN yet, but I'm currently
packaging it for debian unstable. MARC::Record is in there already.
Needless to say, technologies like MARC are massive overkill, but if I'm
going to build my book catalogue, I want to do it right, darn it. :)
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Thu, 08 May 2003 23:58:19 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Sorting book list
Message-Id: <3ebaec81.486062338@news.erols.com>
Gopi Sundaram <gopalan@cs.sc.edu> wrote:
: On Thu, 8 May 2003, Bill Smith wrote:
:
: > @array = sort {a->'author' cmp b->'author' or a->'series' <=>
: > b->'series'} @array;
:
: An author may have multiple series'. The 'series' key contains
: "SeriesName seq_no", for example, "ArabianNights 1".
Bill's question was whether the books in a series can have different
primary authors, not whether one author can have written books in
several series.
: So the series sequence number should only be considered if $a and $b are
: part of the same series.
The core of the problem is that there is no defined sorted order when
$a and $b have the same author but belong to different series.
You need to decide what should happen in that case before trying to
implement the sort.
------------------------------
Date: 8 May 2003 19:58:32 -0700
From: quantum_mechanic_1964@yahoo.com (Quantum Mechanic)
Subject: Re: Subtracting strings [long post]
Message-Id: <f233f2f0.0305081858.7191f4f8@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b8trp1$9hb$2@mamenchi.zrz.TU-Berlin.DE>...
> Well, split() uses the regex mechanism as well, as a look at its first
> parameter shows. Benchmarks show no siginificant difference, though
> split is a tad slower.
Thanks, you're both right, split uses a regex too. <dope slap>
I tried benchmark, and as you said, no significant differences. I was
curious about how repeatable the numbers were, so I ran one of them
twice in the same run. The difference between the duplicates was more
than between any of the others.
Thanks again,
-QM
------------------------------
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.
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 4960
***************************************