[29844] in Perl-Users-Digest
Perl-Users Digest, Issue: 1087 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 2 14:09:44 2007
Date: Sun, 2 Dec 2007 11:09:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 2 Dec 2007 Volume: 11 Number: 1087
Today's topics:
Re: ActiveState Perl 5.10 under Windows XP dilbert1999@gmail.com
Re: Email with text file attachment <ytlim1@gmail.com>
Re: Email with text file attachment <ben@morrow.me.uk>
Increment in nested loop <tlissner@gmail.com>
Re: Increment in nested loop <jurgenex@hotmail.com>
Re: Increment in nested loop <rkb@i.frys.com>
Re: Increment in nested loop <jurgenex@hotmail.com>
Re: Increment in nested loop <rkb@i.frys.com>
new CPAN modules on Sun Dec 2 2007 (Randal Schwartz)
Re: OT raibow <stoupa@practisoft.cz>
Re: OT raibow <stoupa@practisoft.cz>
Re: OT raibow <bik.mido@tiscalinet.it>
Re: OT raibow <bik.mido@tiscalinet.it>
Re: OT raibow <rvtol+news@isolution.nl>
Re: OT raibow <tadmc@seesig.invalid>
Sale CHANELWallet. PRADA. PRADA. CHANEL. GUCCI. Packs. swukong40@gmail.com
Re: Sorted Hash <a1ddaad2-89c6-4b01-bd39-2e27e36ffe39@b <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 2 Dec 2007 10:35:27 -0800 (PST)
From: dilbert1999@gmail.com
Subject: Re: ActiveState Perl 5.10 under Windows XP
Message-Id: <1a0959ff-2fb0-48d0-a6e4-4252929af16f@n20g2000hsh.googlegroups.com>
On Dec 1, 11:42 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> For extra added 5.10-ness I might make that (totally untested)
>
> property for (...);
>
> sub property (_) {
> my $foo = shift;
>
> The new _ prototype character causes an argument to default to $_. :)
I *love* the new _ prototype character and I've tested it with perl
5.10, works like a charm :))
(the only alteration I had to make was to move the line "property for
(...)" below the sub property(_) definition)
------------------------------
Date: Sat, 1 Dec 2007 20:49:58 -0800 (PST)
From: Why Tea <ytlim1@gmail.com>
Subject: Re: Email with text file attachment
Message-Id: <b9daab4c-0e06-4f1f-82e6-86191278ffed@d4g2000prg.googlegroups.com>
> > Yes, it does work, but it's not as flexible and it unnecessarily spawns
> > additional processes. This method of sending an email is not "not very
> > Perlish"; it's most often done in shell scripts. So, do you want to
> > write a shell script or perl script?
>
> Sometimes I want to write a script that works without installing
> additional modules. In medical environments it is simpler to get one
> script validated than a script plus installing new modules.
This is exactly my point although I'm not in the medical field.
> Besides, Perl is a very good glue language, often better suited than the
> shell. So yes, maybe I just want to write a shell script and do it in
> Perl.
Can anyone share a bare minimum plain vanilla Perl script that glues a
few Unix commands to send an email with a text file?
------------------------------
Date: Sun, 2 Dec 2007 08:05:53 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Email with text file attachment
Message-Id: <1k5a25-6g1.ln1@osiris.mauzo.dyndns.org>
Quoth Why Tea <ytlim1@gmail.com>:
>
> Can anyone share a bare minimum plain vanilla Perl script that glues a
> few Unix commands to send an email with a text file?
#!/usr/bin/perl
open my $MAIL, '-|',
mutt =>
-a => '/a/text/file',
-s => 'Test email',
'foo@bar.com'
or die "can't fork mutt: $!";
print $MAIL "Hello world!\n";
close $MAIL or die "sending mail failed: $!";
__END__
Ben
------------------------------
Date: Sun, 02 Dec 2007 16:30:18 GMT
From: Tony Lissner <tlissner@gmail.com>
Subject: Increment in nested loop
Message-Id: <u4B4j.19554$CN4.9743@news-server.bigpond.net.au>
This is a shortened version.
Anyone have any ideas how to get the
inner loop to increment.
Source file unknown number of lines.
Read the file and print two lines per
page until EOF
This is what I want.
Page N
Headers
Two lines on each page
Page 1
Headers
25,Fred,Nerk
23,Foo,Bar
Page 2
Headers
05,perl,v5.8.8
blank line
This is what I get.
Page 1
Headers
25, Fred, Nerk
25, Fred, Nerk
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
my $page_num = 1;
while (<DATA>) {
my ($num, $fname, $lname) = split ',';
print "\nPage $page_num\nHeaders\n";
foreach (1 .. 2) {
print "$num, $fname, $lname";
}
$page_num++;
}
__DATA__
25,Fred,Nerk
23,Foo,Bar
05,perl,v5.8.8
------------------------------
Date: Sun, 02 Dec 2007 17:15:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Increment in nested loop
Message-Id: <_KB4j.6319$Lg.1674@trndny09>
Tony Lissner wrote:
> This is a shortened version.
> Anyone have any ideas how to get the
> inner loop to increment.
>
> Source file unknown number of lines.
> Read the file and print two lines per
> page until EOF
>
> This is what I want.
> Page N
> Headers
> Two lines on each page
>
> Page 1
> Headers
> 25,Fred,Nerk
> 23,Foo,Bar
>
> Page 2
> Headers
> 05,perl,v5.8.8
> blank line
>
> This is what I get.
>
> Page 1
> Headers
> 25, Fred, Nerk
> 25, Fred, Nerk
>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use diagnostics;
>
> my $page_num = 1;
>
> while (<DATA>) {
> my ($num, $fname, $lname) = split ',';
> print "\nPage $page_num\nHeaders\n";
> foreach (1 .. 2) {
> print "$num, $fname, $lname";
> }
You don't do anything with $_ in the inner loop and even have only constants
in the loop condition, therefore this loop is the same as a double
print "$num, $fname, $lname";
print "$num, $fname, $lname";
If you want to print additional lines in the inner loop then you need to
read and split those additional lines in the inner loop, too. That approach
is possible, but IMO not very elegant.
Intead you may want to reconsider your algorithm and read, split(), and
print() each line as you are already doing in the outer while() loop but
injecting that page header at every other line by a simple if() statement:
if ($. % 2 == 0) # Note: $. is the current INPUT_LINE_NUMBER
{print "Header goes here\n";}
jue
------------------------------
Date: Sun, 2 Dec 2007 09:18:27 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: Increment in nested loop
Message-Id: <22c56219-637a-4051-8086-46794fabf95c@i29g2000prf.googlegroups.com>
On Dec 2, 8:30 am, Tony Lissner <tliss...@gmail.com> wrote:
> This is a shortened version.
> Anyone have any ideas how to get the
> inner loop to increment.
>
> Source file unknown number of lines.
> Read the file and print two lines per
> page until EOF
>
> This is what I want.
> Page N
> Headers
> Two lines on each page
>
> Page 1
> Headers
> 25,Fred,Nerk
> 23,Foo,Bar
>
> Page 2
> Headers
> 05,perl,v5.8.8
> blank line
>
> This is what I get.
>
> Page 1
> Headers
> 25, Fred, Nerk
> 25, Fred, Nerk
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use diagnostics;
>
> my $page_num = 1;
>
> while (<DATA>) {
>
> my ($num, $fname, $lname) = split ',';
>
> print "\nPage $page_num\nHeaders\n";
>
> foreach (1 .. 2) {
>
> print "$num, $fname, $lname";
>
> }
> $page_num++;
> }
>
> __DATA__
> 25,Fred,Nerk
> 23,Foo,Bar
> 05,perl,v5.8.8
When I run your code, it outputs exactly what you say you want it to
output.
Here's the output I get.
Page 1
Headers
25, Fred, Nerk
25, Fred, Nerk
Page 2
Headers
23, Foo, Bar
23, Foo, Bar
Page 3
Headers
05, perl, v5.8.8
05, perl, v5.8.8
So, what is it not doing that you want?
------------------------------
Date: Sun, 02 Dec 2007 17:28:54 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Increment in nested loop
Message-Id: <qXB4j.2795$Uy.268@trndny07>
Ron Bergin wrote:
> On Dec 2, 8:30 am, Tony Lissner <tliss...@gmail.com> wrote:
[...]
> When I run your code, it outputs exactly what you say you want it to
> output. Here's the output I get.
>
> Page 1
> Headers
> 25, Fred, Nerk
> 25, Fred, Nerk
> So, what is it not doing that you want?
And this was the desired output:
>> Page 1
>> Headers
>> 25,Fred,Nerk
>> 23,Foo,Bar
The OP forgot to read the next line before printing it.
jue
------------------------------
Date: Sun, 2 Dec 2007 09:44:22 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: Increment in nested loop
Message-Id: <3abfd80c-9c6d-4955-a174-8a93286c30a5@d4g2000prg.googlegroups.com>
On Dec 2, 9:28 am, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
> Ron Bergin wrote:
> > On Dec 2, 8:30 am, Tony Lissner <tliss...@gmail.com> wrote:
> [...]
> > When I run your code, it outputs exactly what you say you want it to
> > output. Here's the output I get.
>
> > Page 1
> > Headers
> > 25, Fred, Nerk
> > 25, Fred, Nerk
> > So, what is it not doing that you want?
>
> And this was the desired output:
>
> >> Page 1
> >> Headers
> >> 25,Fred,Nerk
> >> 23,Foo,Bar
>
> The OP forgot to read the next line before printing it.
>
> jue
Hmmm, I'm just waking up and it looks like I mis-read what was desired.
------------------------------
Date: Sun, 2 Dec 2007 05:42:15 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Dec 2 2007
Message-Id: <JsEqIF.IE2@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.
AxKit-App-TABOO-0.52
http://search.cpan.org/~kjetilk/AxKit-App-TABOO-0.52/
Object Oriented Publishing Framework for AxKit
----
Catalyst-Plugin-Form-Processor-0.05
http://search.cpan.org/~hank/Catalyst-Plugin-Form-Processor-0.05/
Use Form::Processor with Catalyst
----
Class-Std-Fast-0.0.5
http://search.cpan.org/~acid/Class-Std-Fast-0.0.5/
faster but less secure than Class::Std
----
Class-Superclasses-0.03
http://search.cpan.org/~reneeb/Class-Superclasses-0.03/
Find all superclasses of a class
----
Danga-Socket-Callback-0.01200
http://search.cpan.org/~dmaki/Danga-Socket-Callback-0.01200/
Use Danga::Socket From Callbacks
----
EV-ADNS-0.1
http://search.cpan.org/~mlehmann/EV-ADNS-0.1/
----
Email-Date-Format-1.001
http://search.cpan.org/~rjbs/Email-Date-Format-1.001/
produce RFC 822 date strings
----
Form-Processor-0.15
http://search.cpan.org/~hank/Form-Processor-0.15/
validate and process form data
----
GD-Graph-radar-0.0902
http://search.cpan.org/~gene/GD-Graph-radar-0.0902/
Make radial bar charts
----
Games-Mastermind-Cracker-0.02
http://search.cpan.org/~sartak/Games-Mastermind-Cracker-0.02/
quickly crack Mastermind
----
Games-Mastermind-Solver-0.01
http://search.cpan.org/~sartak/Games-Mastermind-Solver-0.01/
quickly solve Mastermind
----
Graph-Weighted-0.14_1
http://search.cpan.org/~gene/Graph-Weighted-0.14_1/
OBSOLETE - An abstract, weighted graph implementation
----
Gungho-0.09005_04
http://search.cpan.org/~dmaki/Gungho-0.09005_04/
Yet Another High Performance Web Crawler Framework
----
GunghoX-FollowLinks-0.00004_01
http://search.cpan.org/~dmaki/GunghoX-FollowLinks-0.00004_01/
Automatically Follow Links Within Responses
----
HTML-StripScripts-LibXML-0.12
http://search.cpan.org/~drtech/HTML-StripScripts-LibXML-0.12/
XSS filter - outputs a LibXML Document or DocumentFragment
----
HTML-StripScripts-Parser-1.02
http://search.cpan.org/~drtech/HTML-StripScripts-Parser-1.02/
XSS filter using HTML::Parser
----
IO-Ppoll-0.04
http://search.cpan.org/~pevans/IO-Ppoll-0.04/
Object interface to Linux's ppoll() call
----
Math-Wavelet-Haar-0.01
http://search.cpan.org/~simcop/Math-Wavelet-Haar-0.01/
Perl extension for transforming data with the Haar Wavelet
----
OLE-Storage_Lite-0.15
http://search.cpan.org/~jmcnamara/OLE-Storage_Lite-0.15/
Simple Class for OLE document interface.
----
Quota-1.6.1
http://search.cpan.org/~tomzo/Quota-1.6.1/
Perl interface to file system quotas
----
SNMP-LogParser-1.0767
http://search.cpan.org/~nito/SNMP-LogParser-1.0767/
An incremental logparser to be used with Net-SNMP
----
SNMP-MibProxy-1.0771
http://search.cpan.org/~nito/SNMP-MibProxy-1.0771/
Simple pass_persist script for Net-SNMP
----
Statistics-Benford-0.06
http://search.cpan.org/~gray/Statistics-Benford-0.06/
calculate the deviation from Benford's Law
----
Sub-Methodical-0.001
http://search.cpan.org/~hdp/Sub-Methodical-0.001/
call methods as functions
----
Sub-Methodical-0.002
http://search.cpan.org/~hdp/Sub-Methodical-0.002/
call methods as functions
----
Test-Harness-3.04
http://search.cpan.org/~andya/Test-Harness-3.04/
Run Perl standard test scripts with statistics
----
Test-Virtual-Filesystem-0.09_01
http://search.cpan.org/~cdolan/Test-Virtual-Filesystem-0.09_01/
Validate a filesystem
----
Text-Template-Simple-0.49_05
http://search.cpan.org/~burak/Text-Template-Simple-0.49_05/
Simple text template engine
----
TinyAuth-0.98
http://search.cpan.org/~adamk/TinyAuth-0.98/
Extremely light-weight web-based authentication manager
----
WWW-Anonymouse-0.04
http://search.cpan.org/~gray/WWW-Anonymouse-0.04/
interface to Anonymouse.org Email and News posting
----
WWW-Facebook-API-v0.4.10
http://search.cpan.org/~unobe/WWW-Facebook-API-v0.4.10/
Facebook API implementation
----
WWW-RobotRules-Parser-0.04001
http://search.cpan.org/~dmaki/WWW-RobotRules-Parser-0.04001/
Just Parse robots.txt
----
WebService-Google-Reader-0.06
http://search.cpan.org/~gray/WebService-Google-Reader-0.06/
Perl interface to Google Reader
----
WebService-Google-Reader-0.07
http://search.cpan.org/~gray/WebService-Google-Reader-0.07/
Perl interface to Google Reader
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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 2 Dec 2007 02:59:34 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: OT raibow
Message-Id: <fit46i$2of6$1@ns.felk.cvut.cz>
Klaus wrote:
> On Dec 1, 4:37 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
>> open H,"> colors.htm";
>
> this is better written using lexical filehandles, open with three
> arguments and test for failure:
> open my $H, '>', 'colors.htm' or die "Error open 'colors.htm', reason: $!";
>
Sorry, I forgot to mention about my Perl version - 5.6.1 ;-)
In addition to this an "or die..." part is not needed for short test-type
scripts when I'm sure about a privileges for directory where script is running
;-)
>> I'm looking for some algorithm what generate the same table but more
>> similar to rainbow. I mean that all red tones will be together, all
>> yellow tones will be together etc. in right order.
>
> http://search.cpan.org/~dland/HTML-Rainbow-0.05/Rainbow.pm
Hurry :-) This is what I'm looking for. Thank you very much. This module work
with character's color and I need to work with background color, but I use and
idea and write some similar.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
------------------------------
Date: Sun, 2 Dec 2007 03:02:36 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: OT raibow
Message-Id: <fit46i$2of6$2@ns.felk.cvut.cz>
A. Sinan Unur wrote:
> "Petr Vileta" <stoupa@practisoft.cz> wrote in
> news:fipin5$vsd$1@ns.felk.cvut.cz:
>
>> My question is not perl specific but here are many clever people :-)
>
> You don't see me asking for restaurant recommendations here, do you?
>
> Sinan
No, thanks ;-) I not need to know good restaurants, but many people here use
Perl for webs and trafic in groups about html or www is 1 message per month
:-(
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
------------------------------
Date: Sun, 02 Dec 2007 12:44:24 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OT raibow
Message-Id: <nq55l3l1egj3q1s9ce6u611votr6qvlhin@4ax.com>
On Sun, 2 Dec 2007 02:59:34 +0100, "Petr Vileta"
<stoupa@practisoft.cz> wrote:
>> this is better written using lexical filehandles, open with three
>> arguments and test for failure:
>> open my $H, '>', 'colors.htm' or die "Error open 'colors.htm', reason: $!";
>>
>Sorry, I forgot to mention about my Perl version - 5.6.1 ;-)
>In addition to this an "or die..." part is not needed for short test-type
>scripts when I'm sure about a privileges for directory where script is running
>;-)
You don't take into account that people could search clpmisc for past
posts. Better let anyone see the ordieish part. At the very least just
put C<or die $!> there. And a smarter answer would have been that you
had
use Fatal 'open';
at the top of your script ;)
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sun, 02 Dec 2007 13:04:02 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OT raibow
Message-Id: <ot65l31ptt477v66rivlufk6f0a1f7lug8@4ax.com>
On 02 Dec 2007 01:00:24 GMT, Joost Diepenmaat <joost@zeekat.nl> wrote:
>> A rainbow contains VERY mixed colors. It's a wonder that these colors
>> are distinguishable by eye at all; they are very low saturation (even if
>> the background is very dark - which it usually is not).
>
>Getting further and further off-topic.
Getting even further offtopic: "Just like a rainbow/you know you set
me free/and I just can't get enough/I just can't get enough."
>I am under the impression that a rainbow contains/is a "frequency sweep"
>of visible light, which would mean that the colors aren't mixed - at
>every point you'd have light of a single frequency.
You're under a wrong impression since strictly speaking light "of a
single frequency" does not exist: all wave packets are spreaded a
little.
>The way the human eye actually processes light means visible light is
>processed as a mixture of stimuli to the 3 types of cone cells, but
>looking at the wiki page*, it seems that all colours except the ones at
>the far ends of the spectrum are detected by at least 2 of the 3 types of
>cell.
Yes, the eye and the ear are very different instruments, with the
latter beying a Fourier transform calculator and the former in some
sense a much rougher one, except for the spatial resolution.
Incidentally I've hear rumors about some researches suggesting that
some people may have a fourth type of cone cells.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sun, 2 Dec 2007 14:54:20 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: OT raibow
Message-Id: <fiuh45.fo.1@news.isolution.nl>
Petr Vileta schreef:
> Sorry, I forgot to mention about my Perl version - 5.6.1 ;-)
http://maddingue.free.fr/conferences/fpw-2007/old-perls/
(5.6 has the 3-argument open)
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 2 Dec 2007 09:38:21 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: OT raibow
Message-Id: <slrnfl5kbd.cub.tadmc@tadmc30.sbcglobal.net>
Petr Vileta <stoupa@practisoft.cz> wrote:
[ snip checking the return value from open() ]
> an "or die..." part is not needed for short test-type
> scripts when I'm sure about a privileges for directory
^
^
When you post code for the whole world to see, then that should
be extended to:
when everyone who sees this code is sure about a privileges for directory
Many people reading this group are learning Perl from it. The may well
copy/paste code found here into their real programs.
"Seeding" the world with poorly formed code is a disservice to the community.
When you post here, the audience that your article is written for is not
really "you", it is to dozens or hundreds or thousands of "us".
(and it is also not seen just "now", it may be seen years from now
in a newsgroup archive.
)
> ;-)
(smiley noted)
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sun, 2 Dec 2007 02:42:53 -0800 (PST)
From: swukong40@gmail.com
Subject: Sale CHANELWallet. PRADA. PRADA. CHANEL. GUCCI. Packs. Some classic packs, etc.
Message-Id: <282534ba-a20b-4205-9781-366dd87f6c82@b40g2000prf.googlegroups.com>
Hello
http://www.shoessuperstar.com/
Founded in 1998, Shoessuperstar Co., Ltd. has become a professional
and credible export company from china.
We can provide you DROPSHIP Service and accept PAYPAL payment which is
different from others!
My website address is: http://www.shoessuperstar.com/
Our main products includes All Fashion Shoes, Hoodist & T-Shirt &
Jeans & Jacket, Bags and MP3/MP4 Players.
Please visit our website to learn more about us and the products. You
will find what you need there!
No matter big or small quantity, we will be your best and faithful
supplier!
We warm welcome you to join us to create a prosperous business
together!
Contact us right now!
EMAIL: swukong116@hotmail.com http://www.shoessuperstar.com/
MSN : shoessuperstar.com@hotmail.com
swukong1@hotmail.com
Yours sincerely
Rolex watches sold JIN Dian
Super Rolex watches sold
------------------------------
Date: Sun, 02 Dec 2007 05:22:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Sorted Hash <a1ddaad2-89c6-4b01-bd39-2e27e36ffe39@b40g2000prf.googlegroups.com> <Xns99F7CDC51277Fasu1cornelledu@127.0.0.1>
Message-Id: <Xns99FA3CBCA05Easu1cornelledu@127.0.0.1>
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote in
news:slrnfl3khq.k4i.hjp-usenet2@zeno.hjp.at:
> On 2007-11-30 01:13, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>> "palexvs@gmail.com" <palexvs@gmail.com> wrote in
>> news:a1ddaad2-89c6-4b01-
>> bd39-2e27e36ffe39@b40g2000prf.googlegroups.com:
>>> I filled hash and then printed it (sorted by key):
>>> my %hs = (
>>> key10 => 5,
>>> key5 => b,
>>> aey9 => 7,
>>> )
>>> foreach my $k (sort keys %hs) { print "$k $hs{$k}\n"; }
>>>
>>> key - string ([0-9A-F]{72}), 50K records.
>>> How do it more effective?
>>
>> Well, depends on what you mean by 'more effective'.
>>
>> If you are talking about speed, note that the only place where you
>> can really get any meaningful improvement is IO.
>
> I don't see anything in your post supporting that claim. So lets try
> it:
>
> print "$_ $hash{$_}\n" for sort keys %hash; 0.217 s
> print "$_ $hash{$_}\n" for keys %hash; 0.112 s
Given the OP's script, the one criterion over which there can be no
doubt is that he wants the output to be sorted.
> The unsorted version is almost twice as fast as the sorted version. So
> eliminating or improving the sort has about the same potential as
> improving I/O.
Clearly, writing a one's own replacement sort routine or copying and
pasting something from somewhere is out of the question. So, the only
way to improve the sort is to pull in a module or two. My intuition told
me that the overhead of that would make the improvement in the context
of this script very underwhelming.
> So how could the sort be sped up or eliminated?
>
> Tie::IxHash keeps the hash sorted, but has quite a lot of overhead. On
> my machine printing the hash takes about 0.465 seconds, which is worse
> than sorting the keys on demand.
Ditto on my system.
> Another way would be to use a faster sort method, as Salvador
> suggested.
I forgot what that was but I tried it at the time and it was slightly
slower.
> Finally, if you either need to print the hash several times or fill it
> in sorted order you could just keep the sorted keys around instead of
> sorting every time.
I meant my response to be critical of the OP's post: There was barely
enough information on requirements in the OP. Given all the information
in the OP regarding the problem and assuming that the OP wanted improve
speed, there is no better way than the simple one liner the OP posted.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>
------------------------------
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 1087
***************************************