[30671] in Perl-Users-Digest
Perl-Users Digest, Issue: 1916 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 11 11:09:41 2008
Date: Sat, 11 Oct 2008 08:09:08 -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 Sat, 11 Oct 2008 Volume: 11 Number: 1916
Today's topics:
Re: "\!" appears on new line <xiaoxia2005a@yahoo.com>
Re: "\!" appears on new line sln@netherlands.com
Re: ($x == ($y or $z)) same as (($x==$y) or ($x==$z)) ? <hjp-usenet2@hjp.at>
Re: <Help> How to use routines from another perl script <hjp-usenet2@hjp.at>
command line with -e <xiaoxia2005a@yahoo.com>
Re: command line with -e <ben@morrow.me.uk>
Re: command line with -e <rvtol+news@isolution.nl>
Re: command line with -e <xiaoxia2005a@yahoo.com>
Re: Date Problem <hjp-usenet2@hjp.at>
how to close STDIN <dontmewithme@got.it>
Re: How to make all available CPU resource to Perl/MySQ <hjp-usenet2@hjp.at>
Re: Loading the shell environment? <hjp-usenet2@hjp.at>
Re: Loading the shell environment? <jurgenex@hotmail.com>
new CPAN modules on Sat Oct 11 2008 (Randal Schwartz)
Re: sort on multiple hash values <hjp-usenet2@hjp.at>
Re: sort on multiple hash values <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 10 Oct 2008 21:19:47 -0700 (PDT)
From: April <xiaoxia2005a@yahoo.com>
Subject: Re: "\!" appears on new line
Message-Id: <5a2fc287-fdbf-49bd-bbe2-3476eeeebae4@h2g2000hsg.googlegroups.com>
On Oct 10, 3:31=A0pm, "John W. Krahn" <some...@example.com> wrote:
> April wrote:
> > this is more concise:
>
> > print "Enter a phrase and convert the first letter to upper case and
> > add a ! at end: ";
> > chomp( my $input =3D <STDIN> );
> > print ucfirst( $input ), "\!", "\n";
>
> TIMTOWTDI:
>
> print "Enter a phrase and convert the first letter to upper case and add
> a ! at end: ";
> ( my $input =3D <STDIN> ) =3D~ s/$/!/;
> print "\u$input";
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0--=
Larry Wall
wow thanks John!
------------------------------
Date: Sat, 11 Oct 2008 04:30:21 GMT
From: sln@netherlands.com
Subject: Re: "\!" appears on new line
Message-Id: <lta0f4d0iou5dj8kle84ifv73pgkrij2bj@4ax.com>
On Fri, 10 Oct 2008 21:19:47 -0700 (PDT), April <xiaoxia2005a@yahoo.com> wrote:
>On Oct 10, 3:31 pm, "John W. Krahn" <some...@example.com> wrote:
>> April wrote:
>> > this is more concise:
>>
>> > print "Enter a phrase and convert the first letter to upper case and
>> > add a ! at end: ";
>> > chomp( my $input = <STDIN> );
>> > print ucfirst( $input ), "\!", "\n";
>>
>> TIMTOWTDI:
>>
>> print "Enter a phrase and convert the first letter to upper case and add
>> a ! at end: ";
>> ( my $input = <STDIN> ) =~ s/$/!/;
>> print "\u$input";
>>
>> John
>> --
>> Perl isn't a toolbox, but a small machine shop where you
>> can special-order certain sorts of tools at low cost and
>> in short order. -- Larry Wall
>
>wow thanks John!
wOW, ITS ALL liKE garbaNZO beans...
sln
------------------------------
Date: Sat, 11 Oct 2008 08:55:39 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: ($x == ($y or $z)) same as (($x==$y) or ($x==$z)) ???
Message-Id: <slrngf0jfb.rjq.hjp-usenet2@hrunkner.hjp.at>
On 2008-10-09 02:32, Jürgen Exner <jurgenex@hotmail.com> wrote:
> kramer <kramer@ufl.edu> wrote:
>>I expected ($x == ($y or $z)) to return true if $x equals either $y or
>>$z. iow to give the same as (($x==$y) or ($x==$z)). But it doesn't.
>>Why?
>
> Because even for Boolean values '==' and 'or' are not distributive, let
> alone for non-Boolean values which you are probably using.
>
> 1 == (0 or 0) ====> 1 == 0 ====> 0
> (1 or 0) == (1 or 0) ====> 1 == 1 ====> 1
He wants to distribute the == over the or, not vice versa, so that
would be:
(1 == 0) or (1 == 0) ====> 0 or 0 ====> 0
works ;-).
Of course it doesn't work in the general case. E.g.,
0 == (0 or 1) ====> 0 == 1 ====> 0
(0 == 0) or (0 == 1) ====> 1 or 0 ====> 1
more specifically, since ($y or $z) returns $y if $y is not false, and
otherwise $z, it works if $x has a true value.
hp
------------------------------
Date: Sat, 11 Oct 2008 10:06:36 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: <Help> How to use routines from another perl script
Message-Id: <slrngf0nkd.rjq.hjp-usenet2@hrunkner.hjp.at>
On 2008-10-07 23:01, Tim Greer <tim@burlyhost.com> wrote:
> Hans Mulder wrote:
>> Tim Greer wrote:
>>> Petr Vileta (fidokomik) wrote:
>>>> require "/var/myroutines/ex1.pl;
>>>
>>> || die, or die, or use eval.
>>
>> Why use "die? "Require" already "die"s when something is wrong.
>>
>> Were you thinking of "do", perhaps?
>>
>
> I was actually making a point about the error (typo) he made in his
> example... as in "what did you want it to do here?" in an attempt at
> humor.
>
> Notice:
>
> require "/var/myroutines/ex1.pl;
>
> is missing the closing ".
That, however, would be caught at compile time, so the presence or
absence of "die" wouldn't make a difference.
hp
------------------------------
Date: Fri, 10 Oct 2008 21:26:52 -0700 (PDT)
From: April <xiaoxia2005a@yahoo.com>
Subject: command line with -e
Message-Id: <2e0ad317-dd06-4c3c-b38c-35ba80dbddd1@y79g2000hsa.googlegroups.com>
I managed to make the following work on my pc:
perl -e "print \"Hello world\n\""
should I be able to also assign value to $_ and then verify it,
possibly in this way just for quick checking?
tried the following but seems not working:
perl -e "$_=2"
perl -e "print \"$_2\n\""
------------------------------
Date: Sat, 11 Oct 2008 05:57:25 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: command line with -e
Message-Id: <lao5s5-abq1.ln1@osiris.mauzo.dyndns.org>
Quoth April <xiaoxia2005a@yahoo.com>:
>
> I managed to make the following work on my pc:
>
> perl -e "print \"Hello world\n\""
>
> should I be able to also assign value to $_ and then verify it,
> possibly in this way just for quick checking?
>
> tried the following but seems not working:
>
> perl -e "$_=2"
>
> perl -e "print \"$_2\n\""
Um... you seem to be somewhat confused. Each separate invocation of perl
is completely separate: variables and such never carry over from one to
the next. If you want to execute several statements one after the other,
you can separate them with ; like this:
perl -e "$_ = 2; print \"$_\n\""
but it's usually better to put them in a file and run that.
If you're running perl from the command line, it's worth getting used to
the q// and qq// forms of quoting. You can rewrite you're first example
as
perl -e "print qq/Hello world\n/"
where the qq means 'double quotes' and the slashes go either end of the
quoted material. This avoids needing to put backslashes all over the
place. Read perldoc perlop for the full details.
If you're just experimenting you can run
perl -de1
which will give you a prompt something like
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(-e:1): 1
DB<1>
where you can type Perl statements which will be immediately run: since
this is all within one execution of perl, variables will carry across
from statement to statement as you seem to expect.
Ben
--
I have two words that are going to make all your troubles go away.
"Miniature". "Golf".
[ben@morrow.me.uk]
------------------------------
Date: Sat, 11 Oct 2008 12:30:29 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: command line with -e
Message-Id: <gcq6e6.1lo.1@news.isolution.nl>
April schreef:
> perl -e "$_=2"
Assigning directly to (the gobal) $_ is not a good style.
Alternative:
my $var = "important data";
for ( $var ) {
s/.*/2/;
}
;)
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sat, 11 Oct 2008 03:50:14 -0700 (PDT)
From: April <xiaoxia2005a@yahoo.com>
Subject: Re: command line with -e
Message-Id: <a07dff39-a417-48ac-bd85-a50e3f1efc87@2g2000hsn.googlegroups.com>
On Oct 11, 12:57=A0am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth April <xiaoxia20...@yahoo.com>:
>
>
>
> > I managed to make the following work on my pc:
>
> > perl -e "print \"Hello world\n\""
>
> > should I be able to also assign value to $_ and then verify it,
> > possibly in this way just for quick checking?
>
> > tried the following but seems not working:
>
> > perl -e "$_=3D2"
>
> > perl -e "print \"$_2\n\""
>
> Um... you seem to be somewhat confused. Each separate invocation of perl
> is completely separate: variables and such never carry over from one to
> the next. If you want to execute several statements one after the other,
> you can separate them with ; like this:
>
> =A0 =A0 perl -e "$_ =3D 2; print \"$_\n\""
>
> but it's usually better to put them in a file and run that.
>
> If you're running perl from the command line, it's worth getting used to
> the q// and qq// forms of quoting. You can rewrite you're first example
> as
>
> =A0 =A0 perl -e "print qq/Hello world\n/"
>
> where the qq means 'double quotes' and the slashes go either end of the
> quoted material. This avoids needing to put backslashes all over the
> place. Read perldoc perlop for the full details.
>
> If you're just experimenting you can run
>
> =A0 =A0 perl -de1
>
> which will give you a prompt something like
>
> =A0 =A0 Loading DB routines from perl5db.pl version 1.28
> =A0 =A0 Editor support available.
>
> =A0 =A0 Enter h or `h h' for help, or `man perldebug' for more help.
>
> =A0 =A0 main::(-e:1): =A0 1
> =A0 =A0 =A0 DB<1>
>
> where you can type Perl statements which will be immediately run: since
> this is all within one execution of perl, variables will carry across
> from statement to statement as you seem to expect.
>
> Ben
>
> --
> I have two words that are going to make all your troubles go away.
> "Miniature". "Golf".
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[b...@morrow.me.uk]
Great Ben, thanks for the very educational reply!
Yes I'm kind of experiemnting, it seems to me at one point I was able
to check what is the current value of $_ and also alter it, using the
command line option?
------------------------------
Date: Sat, 11 Oct 2008 10:28:13 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Date Problem
Message-Id: <slrngf0ost.rjq.hjp-usenet2@hrunkner.hjp.at>
On 2008-10-08 16:26, Tad J McClellan <tadmc@seesig.invalid> wrote:
> Graham Stow <graham.stow@gmail.com> wrote:
>> The following script (or something much like it) runs continuously on
>> a web server
>
> That is likely to waste a boatload of cycles.
Yes, if what the script does once a day is the only thing it does. But
if it provides a useful service continuosly it isn't. (For example it
might be an FCGI script which serves web requests all day long and only
needs to switch log files or dump statistics at the end of each day).
> It would probably be better to run it once a minute or so using
> whatever job scheduling your OS provides, such as "cron".
If it needs to run only at 00:00, why schedule it every minute?
hp
------------------------------
Date: Sat, 11 Oct 2008 16:42:00 +0200
From: Larry <dontmewithme@got.it>
Subject: how to close STDIN
Message-Id: <dontmewithme-B73B72.16420011102008@news.tin.it>
Hi,
i have a script running on a web server (Apache) that accepts data
from STDIN and saves it:
#!/perl
use IO::Handle '_IONBF';
use constant BUFSIZE => 1024 * 2;
my $io = new IO::Handle;
if ( $io->fdopen(fileno(STDIN),"r") )
{
while($io->read($buf, BUFSIZE))
{
# ... save $buf ...
}
$io->close;
}
__END__;
I decided to check out if a user can upload to this script or else my
web server would screw up. So I put this on top of my script:
if ($ENV{"HTTP_USER_PASS"} ne 'mypassword')
{
close STDIN;
exit;
}
then I sent a couple of MBs of data thru http without the USER_PASS
header, i was struck by my finding out the script sort of died but I was
still sending raw data to the script...I though close STDIN would drop
the connection, too bad it didn't...how can I sort this out?
thanks
------------------------------
Date: Sat, 11 Oct 2008 09:55:31 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: How to make all available CPU resource to Perl/MySQL in Win XP?
Message-Id: <slrngf0mvk.rjq.hjp-usenet2@hrunkner.hjp.at>
On 2008-10-09 09:49, evillen@gmail.com <evillen@gmail.com> wrote:
> On 9 Oct, 09:53, Joost Diepenmaat <jo...@zeekat.nl> wrote:
>> "evil...@gmail.com" <evil...@gmail.com> writes:
>> > I have used the SysInternals Process Explorer's "Set Priority" feature
>> > & set both .exe's to Realtime24 but this had negligible effect.
>>
>> > How can I force the .exe's to make better use of the CPU?
>>
>> You want a different algorithm so that you're not waiting on network IO
>> / disc IO / other system calls / file locks / database locks.
>
> Can you recommend some way of detecting these 'gating processes'
What are 'gating processes'?
> or 'locks'?
See chapter 7 of the MySQL manual.
> There is no Network IO & minimal Disk IO required by my program &
How did you determine that there is "minimal disk I/O"? Disk I/O is
frequently the bottleneck of database applications. How much time does
Mysql spend in disk I/O?
hp
------------------------------
Date: Sat, 11 Oct 2008 09:25:15 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Loading the shell environment?
Message-Id: <slrngf0l6t.rjq.hjp-usenet2@hrunkner.hjp.at>
On 2008-10-10 16:23, Jürgen Exner <jurgenex@hotmail.com> wrote:
> T <g4173c@motorola.com> wrote:
[ you snipped the relevant part of the posting which included
eval `/some/command bash other parameters`
eval `/some/command tcsh other parameters`
]
>>a shell wrapper around my Perl script. Does anyone know how to load
>>the shell environment
>>in a Perl script? This script will run in crontab file that's why I
>>need to load the env.
>
> This is a variation of 'perldoc -q environment'.
> The `...` starts a child process, runs the modulecmd command in that
> child process, and then throws away the results because parent processes
> don't inherit environment changes from their children.
No. The child process doesn't set the environment. The child process
prints commands (presumably in "bash" or "tcsh" syntax, guessing from
the parameters), which are then evaled by the parent process to set the
environment.
The problem is of course that Perl is a different language from both
bash and tcsh and therefore cannor eval bash or tcsh commands. The child
process would need to spit out perl statements for that to work. Maybe
it can be modified so that
eval `/some/command perl other parameters`
does the right thing. Otherwise, use Ben's approach (actually, I would
prefer Ben's approach anyway).
hp
------------------------------
Date: Sat, 11 Oct 2008 01:28:12 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Loading the shell environment?
Message-Id: <1po0f4dn7kbt8k7kqedjjad19a72f4h7un@4ax.com>
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>On 2008-10-10 16:23, Jürgen Exner <jurgenex@hotmail.com> wrote:
>> T <g4173c@motorola.com> wrote:
>
>[ you snipped the relevant part of the posting which included
>
> eval `/some/command bash other parameters`
> eval `/some/command tcsh other parameters`
>
>]
>
>>>a shell wrapper around my Perl script. Does anyone know how to load
>>>the shell environment
>>>in a Perl script? This script will run in crontab file that's why I
>>>need to load the env.
>>
>> This is a variation of 'perldoc -q environment'.
>> The `...` starts a child process, runs the modulecmd command in that
>> child process, and then throws away the results because parent processes
>> don't inherit environment changes from their children.
>
>No. The child process doesn't set the environment. The child process
>prints commands (presumably in "bash" or "tcsh" syntax, guessing from
>the parameters), which are then evaled by the parent process to set the
>environment.
You are right, I misread the problem. Thanks for pointing this out.
jue
------------------------------
Date: Sat, 11 Oct 2008 04:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Oct 11 2008
Message-Id: <K8K52M.ELE@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
AnyEvent-CouchDB-1.03
http://search.cpan.org/~beppu/AnyEvent-CouchDB-1.03/
a non-blocking CouchDB client based on jquery.couch.js
----
Archive-Extract-0.28
http://search.cpan.org/~kane/Archive-Extract-0.28/
A generic archive extracting mechanism
----
Archive-Zip-1.25
http://search.cpan.org/~adamk/Archive-Zip-1.25/
Provide an interface to ZIP archive files.
----
Business-Intelligence-MicroStrategy-CommandManager-0.01
http://search.cpan.org/~cgrady/Business-Intelligence-MicroStrategy-CommandManager-0.01/
The MicroStrategy Command Manager module
----
CPAN-Testers-WWW-Statistics-0.52
http://search.cpan.org/~barbie/CPAN-Testers-WWW-Statistics-0.52/
CPAN Testers Statistics website.
----
Class-DBI-Lite-0.012
http://search.cpan.org/~johnd/Class-DBI-Lite-0.012/
Lightweight ORM for Perl
----
Crypt-Tea_JS-2.20
http://search.cpan.org/~pjb/Crypt-Tea_JS-2.20/
The Tiny Encryption Algorithm in Perl and JavaScript
----
Crypt-Tea_JS-2.21
http://search.cpan.org/~pjb/Crypt-Tea_JS-2.21/
The Tiny Encryption Algorithm in Perl and JavaScript
----
DBD-ODBC-1.17_1
http://search.cpan.org/~mjevans/DBD-ODBC-1.17_1/
ODBC Driver for DBI
----
Export-Lexical-0.0.3
http://search.cpan.org/~cgrau/Export-Lexical-0.0.3/
Lexically scoped subroutine imports
----
File-Fetch-0.16
http://search.cpan.org/~kane/File-Fetch-0.16/
A generic file fetching mechanism
----
Finance-TickerSymbols-1.02
http://search.cpan.org/~jezra/Finance-TickerSymbols-1.02/
Perl extension for getting symbols lists from web resources
----
Games-Risk-1.1.3
http://search.cpan.org/~jquelin/Games-Risk-1.1.3/
classical 'risk' board game
----
HTML-ExtractContent-0.01
http://search.cpan.org/~tarao/HTML-ExtractContent-0.01/
An HTML content extractor with scoring heuristics
----
IPC-Cmd-0.42
http://search.cpan.org/~kane/IPC-Cmd-0.42/
finding and running system commands made easy
----
IRC-Bot-Log-Extended-0.01
http://search.cpan.org/~fayland/IRC-Bot-Log-Extended-0.01/
extends IRC::Bot::Log for IRC::Bot
----
IRC-Bot-Log-Extended-0.02
http://search.cpan.org/~fayland/IRC-Bot-Log-Extended-0.02/
extends IRC::Bot::Log for IRC::Bot
----
Imager-SkinDetector-0.03
http://search.cpan.org/~cosimo/Imager-SkinDetector-0.03/
The great new Imager::SkinDetector!
----
LUGS-Events-Parser-0.03
http://search.cpan.org/~schubiger/LUGS-Events-Parser-0.03/
Event parser for the Linux User Group Switzerland
----
LWP-UserAgent-ProxyHopper-0.004
http://search.cpan.org/~zoffix/LWP-UserAgent-ProxyHopper-0.004/
LWP::UserAgent with proxi-hopping
----
Mail-DWIM-0.05
http://search.cpan.org/~mschilli/Mail-DWIM-0.05/
Do-What-I-Mean Mailer
----
Mail-Log-Exceptions-1.0
http://search.cpan.org/~dstaal/Mail-Log-Exceptions-1.0/
Exceptions for the Mail::Log::* modules.
----
Mail-Log-Parse-1.0
http://search.cpan.org/~dstaal/Mail-Log-Parse-1.0/
Parse and return info in maillogs
----
Module-Setup-0.03_01
http://search.cpan.org/~yappo/Module-Setup-0.03_01/
a simple module maker "yet another Module::Start(?:er)?"
----
Net-BitTorrent-0.027_005
http://search.cpan.org/~sanko/Net-BitTorrent-0.027_005/
BitTorrent peer-to-peer protocol class
----
Net-IMAP-Simple-Plus-1.17
http://search.cpan.org/~jettero/Net-IMAP-Simple-Plus-1.17/
----
Net-IMAP-Simple-Plus-1.17_001
http://search.cpan.org/~jettero/Net-IMAP-Simple-Plus-1.17_001/
NIS 1.71 plus a couple patches
----
POE-Component-SmokeBox-0.01_07
http://search.cpan.org/~bingos/POE-Component-SmokeBox-0.01_07/
POE enabled CPAN smoke testing with added value.
----
POEIKC-0.04
http://search.cpan.org/~suzuki/POEIKC-0.04/
A framework to make a daemon or P2P with "PoCo::IKC"
----
Provision-Unix-0.28
http://search.cpan.org/~msimerson/Provision-Unix-0.28/
provision accounts on unix systems
----
RTG-Report-1.16
http://search.cpan.org/~msimerson/RTG-Report-1.16/
RTG reporting and data processing utilities
----
SQL-DB-0.15
http://search.cpan.org/~mlawren/SQL-DB-0.15/
Perl interface to SQL Databases
----
SVN-Hooks-0.12.410
http://search.cpan.org/~gnustavo/SVN-Hooks-0.12.410/
A framework for implementing Subversion hooks.
----
SVN-Look-0.12.409
http://search.cpan.org/~gnustavo/SVN-Look-0.12.409/
A caching wrapper aroung the svnlook command.
----
Test-Database-0.01
http://search.cpan.org/~book/Test-Database-0.01/
Database handles ready for testing
----
Text-Metaphone-2.01
http://search.cpan.org/~mschwern/Text-Metaphone-2.01/
A modern soundex. Phonetic encoding of words.
----
Text-Template-Simple-0.62_03
http://search.cpan.org/~burak/Text-Template-Simple-0.62_03/
Simple text template engine
----
Text-Template-Simple-0.62_04
http://search.cpan.org/~burak/Text-Template-Simple-0.62_04/
Simple text template engine
----
WWW-CPANRatings-RSS-0.0304
http://search.cpan.org/~zoffix/WWW-CPANRatings-RSS-0.0304/
get information from RSS feed on http://cpanratings.perl.org/
----
WWW-FreeProxy-0.03
http://search.cpan.org/~swined/WWW-FreeProxy-0.03/
fetch proxies from free proxy lists
----
WWW-Netflix-API-0.03
http://search.cpan.org/~davidrw/WWW-Netflix-API-0.03/
Interface for Netflix's API
----
XML-Compile-0.96
http://search.cpan.org/~markov/XML-Compile-0.96/
Compilation based XML processing
----
XML-Compile-SOAP-0.78
http://search.cpan.org/~markov/XML-Compile-SOAP-0.78/
base-class for SOAP implementations
----
ZConf-0.6.0
http://search.cpan.org/~vvelox/ZConf-0.6.0/
A configuration system allowing for either file or LDAP backed storage.
----
libwww-perl-5.817
http://search.cpan.org/~gaas/libwww-perl-5.817/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Sat, 11 Oct 2008 09:43:07 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: sort on multiple hash values
Message-Id: <slrngf0m8c.rjq.hjp-usenet2@hrunkner.hjp.at>
On 2008-10-08 18:04, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Zhiliang Hu <zhilianghu@gmail.com> wrote:
>>I have a hash with multiple values, like in:
>>
>> Marty => 32877::2
>> Bart => 14857::2
>> Torq => 65221::1
>> etc
>>
>>and I wish to sort on. say, first field of the hash value:
>
> You don't because hashes by definition do not have a sequence and
> therefore cannot be sorted.
Jürgen, can you please try to be little less literal? I see no
indication that the OP wanted to create a hash with an intrinsic sort
order.
> What _do_ you want to sort? An array of the keys of the hash? An arrray
> of the values of the hash?
One of those two, almost certainly. It doesn't really matter, since the
technique is the same, you just write
sort { cmp_func($hash{$a}, $hash{$b}) } keys %hash
in one case and
sort { cmp_func($a, $b) } values %hash
in the other (the OP already stated that the sort order depends only on
the value, not the key).
> Something totally different?
Unlikely.
> See also the FAQ: "How do I sort a hash[...]?"
I don't see you berating Brian that he can't sort a hash ...
hp
------------------------------
Date: Sat, 11 Oct 2008 01:50:10 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: sort on multiple hash values
Message-Id: <51p0f4t7rirq5488oqj7nceosmgmj8iml8@4ax.com>
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>On 2008-10-08 18:04, Jürgen Exner <jurgenex@hotmail.com> wrote:
>> Zhiliang Hu <zhilianghu@gmail.com> wrote:
>>>I have a hash with multiple values, like in:
>>>
>>> Marty => 32877::2
>>> Bart => 14857::2
>>> Torq => 65221::1
>>> etc
>>>
>>>and I wish to sort on. say, first field of the hash value:
>>
>> You don't because hashes by definition do not have a sequence and
>> therefore cannot be sorted.
>
>Jürgen, can you please try to be little less literal? I see no
>indication that the OP wanted to create a hash with an intrinsic sort
>order.
I guess that's my pet peeve. If people would stop talking about sorting
a hash and instead spend just a minute thinking about what they _REALLY_
want to do, then the solution would be obvious, please see below.
[...]
> sort { cmp_func($hash{$a}, $hash{$b}) } keys %hash
This is I want to sort the keys of the hash by their associated values,
using some criteria.
>in one case and
> sort { cmp_func($a, $b) } values %hash
And this is I want to sort the values of the hash by their own values,
using some criteria.
Both follow the standard pattern "I want to sort X by criteria Y". The
solution will jump right at you once you recognize that sort() takes two
parameters: the compare function and the list(!) of data to be sorted.
So first get that list (no, it is not the hash!), and then based on the
elements in that list define your compare function.
Once you forget the idea about sorting a hash and realize that actually
you are sorting a list and that you have to create that list first, then
the problem looses the 'rocket science complexity' and becomes trivial.
Unfortunately most people keep insisting on thinking in terms of sorting
a hash.... :-((
jue
------------------------------
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 V11 Issue 1916
***************************************