[30390] in Perl-Users-Digest
Perl-Users Digest, Issue: 1633 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 12 03:09:38 2008
Date: Thu, 12 Jun 2008 00:09: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, 12 Jun 2008 Volume: 11 Number: 1633
Today's topics:
Re: FAQ 7.14 What is variable suicide and how can I pre <bill@ts1000.us>
Re: FAQ 7.14 What is variable suicide and how can I pre <someone@example.com>
Re: FAQ 7.14 What is variable suicide and how can I pre <bill@ts1000.us>
Re: FAQ 7.26 How can I find out my current package? <brian.d.foy@gmail.com>
Re: FAQ 7.26 How can I find out my current package? <brian.d.foy@gmail.com>
Re: How to close all started Internet Explorer from per <bill@ts1000.us>
Re: How to close all started Internet Explorer from per <jurgenex@hotmail.com>
new CPAN modules on Thu Jun 12 2008 (Randal Schwartz)
Re: OT: please help me for my script <john.swilting@wanadoo.fr>
Re: OT: please help me for my script <danrumney@warpmail.net>
Re: OT: please help me for my script <jurgenex@hotmail.com>
Re: sorting a hash / 2008-06-01 <whynot@pozharski.name>
Re: sorting a hash / 2008-06-01 <uri@stemsystems.com>
Re: Time and again <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 11 Jun 2008 16:07:05 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: FAQ 7.14 What is variable suicide and how can I prevent it?
Message-Id: <a72f0e8e-7e89-4655-a129-56f5e42af350@t54g2000hsg.googlegroups.com>
On Jun 11, 9:03=A0am, PerlFAQ Server <br...@stonehenge.com> wrote:
> This is an excerpt from the latest version perlfaq7.pod, which
> comes with the standard Perl distribution. These postings aim to
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is athttp://faq.perl.org.
>
> --------------------------------------------------------------------
>
> 7.14: What is variable suicide and how can I prevent it?
>
> =A0 =A0 This problem was fixed in perl 5.004_05, so preventing it means
> =A0 =A0 upgrading your version of perl. ;)
>
> =A0 =A0 Variable suicide is when you (temporarily or permanently) lose the=
value
> =A0 =A0 of a variable. It is caused by scoping through my() and local()
> =A0 =A0 interacting with either closures or aliased foreach() iterator var=
iables
> =A0 =A0 and subroutine arguments. It used to be easy to inadvertently lose=
a
> =A0 =A0 variable's value this way, but now it's much harder. Take this cod=
e:
>
> =A0 =A0 =A0 =A0 =A0 =A0 my $f =3D 'foo';
> =A0 =A0 =A0 =A0 =A0 =A0 sub T {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while ($i++ < 3) { my $f =3D $f; $=
f .=3D "bar"; print $f, "\n" }
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 =A0 =A0 T;
> =A0 =A0 =A0 =A0 =A0 =A0 print "Finally $f\n";
>
> =A0 =A0 If you are experiencing variable suicide, that "my $f" in the subr=
outine
> =A0 =A0 doesn't pick up a fresh copy of the $f whose value is <foo>. The o=
utput
> =A0 =A0 shows that inside the subroutine the value of $f leaks through whe=
n it
> =A0 =A0 shouldn't, as in this output:
>
> =A0 =A0 =A0 =A0 =A0 =A0 foobar
> =A0 =A0 =A0 =A0 =A0 =A0 foobarbar
> =A0 =A0 =A0 =A0 =A0 =A0 foobarbarbar
> =A0 =A0 =A0 =A0 =A0 =A0 Finally foo
>
> =A0 =A0 The $f that has "bar" added to it three times should be a new $f "=
my $f"
> =A0 =A0 should create a new lexical variable each time through the loop. T=
he
> =A0 =A0 expected output is:
>
> =A0 =A0 =A0 =A0 =A0 =A0 foobar
> =A0 =A0 =A0 =A0 =A0 =A0 foobar
> =A0 =A0 =A0 =A0 =A0 =A0 foobar
> =A0 =A0 =A0 =A0 =A0 =A0 Finally foo
>
> --------------------------------------------------------------------
>
> The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
> are not necessarily experts in every domain where Perl might show up,
> so please include as much information as possible and relevant in any
> corrections. The perlfaq-workers also don't have access to every
> operating system or platform, so please include relevant details for
> corrections to examples that do not work on particular platforms.
> Working code is greatly appreciated.
>
> If you'd like to help maintain the perlfaq, see the details in
> perlfaq.pod.
Two things:
1) this just explains the behaviour - it doesn't say what to do
(unless I am blind)
2) what is the T; after the sub T? I have never see a construct like
that to close a subroutine, I thought the { } took care of containing
the subroutine.
Bill H
------------------------------
Date: Thu, 12 Jun 2008 00:02:34 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: FAQ 7.14 What is variable suicide and how can I prevent it?
Message-Id: <uIZ3k.961$L03.338@edtnps92>
Bill H wrote:
> On Jun 11, 9:03 am, PerlFAQ Server <br...@stonehenge.com> wrote:
>>
>> my $f = 'foo';
>> sub T {
>> while ($i++ < 3) { my $f = $f; $f .= "bar"; print $f, "\n" }
>> }
>>
>> T;
>> print "Finally $f\n";
>
> 2) what is the T; after the sub T?
sub T { ... } defines the subtoutine and the next line T; calls the
subroutine just defined.
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
------------------------------
Date: Wed, 11 Jun 2008 18:22:39 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: FAQ 7.14 What is variable suicide and how can I prevent it?
Message-Id: <dc99c45f-7b56-4bf1-9e2b-2259cec5671b@j22g2000hsf.googlegroups.com>
On Jun 11, 8:02=A0pm, "John W. Krahn" <some...@example.com> wrote:
> Bill H wrote:
> > On Jun 11, 9:03 am, PerlFAQ Server <br...@stonehenge.com> wrote:
>
> >> =A0 =A0 =A0 =A0 =A0 =A0 my $f =3D 'foo';
> >> =A0 =A0 =A0 =A0 =A0 =A0 sub T {
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while ($i++ < 3) { my $f =3D $f=
; $f .=3D "bar"; print $f, "\n" }
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> >> =A0 =A0 =A0 =A0 =A0 =A0 T;
> >> =A0 =A0 =A0 =A0 =A0 =A0 print "Finally $f\n";
>
> > 2) what is the T; after the sub T?
>
> sub T { ... } defines the subtoutine and the next line T; calls the
> subroutine just defined.
>
> 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
Du'h how did I miss that - Thanks John!
Bill H
------------------------------
Date: Wed, 11 Jun 2008 17:13:39 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 7.26 How can I find out my current package?
Message-Id: <110620081713393992%brian.d.foy@gmail.com>
In article <gDR3k.149590$TT4.28337@attbi_s22>, Michael Carman
<mjcarman@mchsi.com> wrote:
> Uri Guttman wrote:
> >>>>>> "MC" == Michael Carman <mjcarman@mchsi.com> writes:
> >
> > >> 7.26: How can I find out my current package?
> > MC> The answer doesn't mention caller() but probably should.
> >
> > the question is current package, not the called from
> > package. __PACKAGE__ is all that is needed.
>
> Mentioning caller() here seems just as appropriate as the mention of
> ref(). I can understand the subtleties of why you'd consider ref() to be
> the current package but the people who need this FAQ answer won't.
Well, caller is more appropriate :)
> I don't think a strict interpretation of this question (or FAQ questions
> in general) is warranted.
I agree. I've replaced the answer to talk about __PACKAGE__, blessed,
and caller.
Thanks,
------------------------------
Date: Wed, 11 Jun 2008 17:18:43 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 7.26 How can I find out my current package?
Message-Id: <110620081718432214%brian.d.foy@gmail.com>
In article <864p80c6y4.fsf@mithril.chromatico.net>, Charlton Wilbur
<cwilbur@chromatico.net> wrote:
> >>>>> "MC" == Michael Carman <mjcarman@mchsi.com> writes:
>
> MC> From a practical point of view there doesn't appear to be an FAQ
> MC> entry for the called from package. (Neither "perldoc -q package"
> MC> nor "perldoc -q call" find anything.) It would fit nicely here.
>
> I'm sure a patch would be welcome.
No need, I think. I changed the question to
How can I find out my current or calling package?
Thanks,
------------------------------
Date: Wed, 11 Jun 2008 15:24:45 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: How to close all started Internet Explorer from perl scripts?
Message-Id: <1a57802a-96e0-414a-8356-13c4a51d55a3@79g2000hsk.googlegroups.com>
On Jun 11, 6:08=A0pm, "Pero" <p...@tupwerwt.ch> wrote:
> How to close all started Internet Explorer from perl scripts?
>
> Tnx.
#!/usr/bin/perl
use strict;
use warnings;
print "Content-type:text/html\n\n";
print "<HTML><BODY><P>Press ALT F4</P></BODY></HTML>\n";
exit;
BIll H
Sorry - had to
------------------------------
Date: Thu, 12 Jun 2008 01:38:45 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to close all started Internet Explorer from perl scripts?
Message-Id: <65v05450ftdus0ptuudet0iir6j6j0n30g@4ax.com>
"Pero" <pero@tupwerwt.ch> wrote:
>How to close all started Internet Explorer from perl scripts?
I am sure there is a more Windowish way but one way to do it:
Install the SFU kit (free from the MS website).
Then run
system ('kill iexplore');
from your Perl program. That shall do it.
jue
------------------------------
Date: Thu, 12 Jun 2008 04:42:21 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Jun 12 2008
Message-Id: <K2C2EL.171z@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.
Acme-Terror-UK-0.04
http://search.cpan.org/~rprice/Acme-Terror-UK-0.04/
Fetch the current UK terror alert level
----
App-Nopaste-0.04
http://search.cpan.org/~sartak/App-Nopaste-0.04/
easy access to any pastebin
----
B-Flags-0.02
http://search.cpan.org/~ams/B-Flags-0.02/
Friendlier flags for B
----
BDB-Wrapper-0.10
http://search.cpan.org/~hikarine/BDB-Wrapper-0.10/
Wrapper module for BerkeleyDB.pm
----
CPAN-Reporter-Smoker-0.13
http://search.cpan.org/~dagolden/CPAN-Reporter-Smoker-0.13/
Turnkey CPAN Testers smoking
----
CPANPLUS-Dist-Mdv-0.3.6
http://search.cpan.org/~jquelin/CPANPLUS-Dist-Mdv-0.3.6/
a cpanplus backend to build mandriva rpms
----
Catalyst-Plugin-Authentication-0.10007_01
http://search.cpan.org/~jrobinson/Catalyst-Plugin-Authentication-0.10007_01/
Infrastructure plugin for the Catalyst authentication framework.
----
Class-Method-Modifiers-1.00
http://search.cpan.org/~sartak/Class-Method-Modifiers-1.00/
provides Moose-like method modifiers
----
DBIx-Class-RandomStringColumns-0.05
http://search.cpan.org/~mikihoshi/DBIx-Class-RandomStringColumns-0.05/
Implicit random string columns
----
Data-Omap-0.06
http://search.cpan.org/~bbaxter/Data-Omap-0.06/
Perl module to implement ordered mappings
----
Data-Pairs-0.06
http://search.cpan.org/~bbaxter/Data-Pairs-0.06/
Perl module to implement ordered mappings with possibly duplicate keys.
----
Enbugger-2.000
http://search.cpan.org/~whitepage/Enbugger-2.000/
Enables the debugger at runtime.
----
File-Assets-0.060_3
http://search.cpan.org/~rkrimen/File-Assets-0.060_3/
Manage .css and .js assets in a web application
----
File-Assets-0.060_4
http://search.cpan.org/~rkrimen/File-Assets-0.060_4/
Manage .css and .js assets in a web application
----
File-Assets-0.060_5
http://search.cpan.org/~rkrimen/File-Assets-0.060_5/
Manage .css and .js assets in a web application
----
File-Find-Rule-Age-0.1.1
http://search.cpan.org/~pfig/File-Find-Rule-Age-0.1.1/
rule to match on file age
----
File-Find-Rule-Age-0.2
http://search.cpan.org/~pfig/File-Find-Rule-Age-0.2/
rule to match on file age
----
Graphics-GnuplotIF-1.5
http://search.cpan.org/~mehner/Graphics-GnuplotIF-1.5/
A dynamic Perl interface to gnuplot
----
HTTP-Engine-0.0.11
http://search.cpan.org/~yappo/HTTP-Engine-0.0.11/
Web Server Gateway Interface and HTTP Server Engine Drivers (Yet Another Catalyst::Engine)
----
IPC-Run-SafeHandles-0.02
http://search.cpan.org/~clkao/IPC-Run-SafeHandles-0.02/
Use IPC::Run and IPC::Run3 safely
----
InSilicoSpectro-Databanks-0.0.40
http://search.cpan.org/~alexmass/InSilicoSpectro-Databanks-0.0.40/
parsing protein/nucleotides sequence databanks (fasta, uniprot...)
----
LEOCHARRE-CLI-1.19
http://search.cpan.org/~leocharre/LEOCHARRE-CLI-1.19/
useful subs for coding cli scripts
----
Lingua-EN-NamedEntity-1.8
http://search.cpan.org/~ambs/Lingua-EN-NamedEntity-1.8/
Basic Named Entity Extraction algorithm
----
Lingua-SA-0.08
http://search.cpan.org/~aschig/Lingua-SA-0.08/
Perl extension for the language Sanskrit
----
Linux-Taskstats-Read-6.01
http://search.cpan.org/~scottw/Linux-Taskstats-Read-6.01/
Read Linux taskstats structures
----
Math-Geometry-Voronoi-1.0
http://search.cpan.org/~samtregar/Math-Geometry-Voronoi-1.0/
compute Voronoi diagrams from sets of points
----
Math-Random-MT-Auto-6.14
http://search.cpan.org/~jdhedden/Math-Random-MT-Auto-6.14/
Auto-seeded Mersenne Twister PRNGs
----
Metadata-DB-1.12
http://search.cpan.org/~leocharre/Metadata-DB-1.12/
----
Mouse-0.02
http://search.cpan.org/~sartak/Mouse-0.02/
Moose minus the antlers
----
Nagios-Plugin-DieNicely-0.02
http://search.cpan.org/~jlmartin/Nagios-Plugin-DieNicely-0.02/
Die in a Nagios output compatible way
----
Net-SCP-Expect-0.13
http://search.cpan.org/~rybskej/Net-SCP-Expect-0.13/
Wrapper for scp that allows passwords via Expect.
----
Net-Twitter-1.14
http://search.cpan.org/~cthom/Net-Twitter-1.14/
Perl interface to twitter.com
----
ONTO-PERL-1.13
http://search.cpan.org/~easr/ONTO-PERL-1.13/
----
POE-Component-CPAN-Reporter-0.01_00
http://search.cpan.org/~bingos/POE-Component-CPAN-Reporter-0.01_00/
Bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPAN-Reporter-0.01_01
http://search.cpan.org/~bingos/POE-Component-CPAN-Reporter-0.01_01/
Bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPAN-Reporter-0.01_02
http://search.cpan.org/~bingos/POE-Component-CPAN-Reporter-0.01_02/
Bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPAN-Reporter-0.01_03
http://search.cpan.org/~bingos/POE-Component-CPAN-Reporter-0.01_03/
Bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPAN-Reporter-0.01_04
http://search.cpan.org/~bingos/POE-Component-CPAN-Reporter-0.01_04/
Bringing the power of POE to CPAN smoke testing.
----
POE-Component-Server-SOAP-1.12
http://search.cpan.org/~apocal/POE-Component-Server-SOAP-1.12/
publish POE event handlers via SOAP over HTTP
----
POE-Component-SimpleLog-1.05
http://search.cpan.org/~apocal/POE-Component-SimpleLog-1.05/
Perl extension to manage a simple logging system for POE.
----
Perl-AtEndOfScope-0.02
http://search.cpan.org/~opi/Perl-AtEndOfScope-0.02/
run some code when a variable goes out of scope
----
Rose-DBx-Object-Renderer-0.09
http://search.cpan.org/~danny/Rose-DBx-Object-Renderer-0.09/
Web UI Rendering for Rose::DB::Object
----
Rose-DBx-Object-Renderer-0.10
http://search.cpan.org/~danny/Rose-DBx-Object-Renderer-0.10/
Web UI Rendering for Rose::DB::Object
----
SVG-Graph-0.02
http://search.cpan.org/~allenday/SVG-Graph-0.02/
Visualize your data in Scalable Vector Graphics (SVG) format.
----
Slay-Makefile-Gress-0.05
http://search.cpan.org/~nodine/Slay-Makefile-Gress-0.05/
Use Slay::Makefile for software regression testing
----
Sledge-Config-YAML-0.07
http://search.cpan.org/~mikihoshi/Sledge-Config-YAML-0.07/
The configuration file of Sledge can be written by using YAML.
----
Socket-Class-1.22
http://search.cpan.org/~chrmue/Socket-Class-1.22/
A class to communicate with sockets
----
Statistics-Contingency-0.07
http://search.cpan.org/~kwilliams/Statistics-Contingency-0.07/
Calculate precision, recall, F1, accuracy, etc.
----
String-Prettify-1.03
http://search.cpan.org/~leocharre/String-Prettify-1.03/
subs to cleanup a filename and or garble for human eyes
----
Sub-Become-0.01
http://search.cpan.org/~andya/Sub-Become-0.01/
Syntactic sugar to allow a sub to replace itself
----
Sys-Info-0.52_3
http://search.cpan.org/~burak/Sys-Info-0.52_3/
Fetch information from the host system
----
SystemTray-Applet-Gnome-0.02
http://search.cpan.org/~psinnott/SystemTray-Applet-Gnome-0.02/
Gnome support for SystemTray::Applet
----
Test-Aggregate-0.21
http://search.cpan.org/~ovid/Test-Aggregate-0.21/
Aggregate *.t tests to make them run faster.
----
Test-Aggregate-0.22
http://search.cpan.org/~ovid/Test-Aggregate-0.22/
Aggregate *.t tests to make them run faster.
----
Test-Fixme-0.03
http://search.cpan.org/~evdb/Test-Fixme-0.03/
check code for FIXMEs.
----
Tripletail-0.43
http://search.cpan.org/~hio/Tripletail-0.43/
Tripletail, Framework for Japanese Web Application
----
Unicode-Unihan-0.04
http://search.cpan.org/~dankogai/Unicode-Unihan-0.04/
The Unihan Data Base 5.1.0
----
WWW-Mechanize-Plugin-Web-Scraper-0.01
http://search.cpan.org/~blom/WWW-Mechanize-Plugin-Web-Scraper-0.01/
Scrape the planet!
----
WikiText-Socialtext-0.10
http://search.cpan.org/~ingy/WikiText-Socialtext-0.10/
Socialtext WikiText Module
----
Win32-WindowsMedia-0.257
http://search.cpan.org/~shamrock/Win32-WindowsMedia-0.257/
Base Module for Provisiong and control for Windows Media Services
----
XLSperl-0.6
http://search.cpan.org/~jonallen/XLSperl-0.6/
use Perl "one-liners" with Microsoft Excel files
----
XML-RelaxNG-Compact-PXB-0.05
http://search.cpan.org/~mpg/XML-RelaxNG-Compact-PXB-0.05/
create perl XML (RelaxNG Compact) data binding API
----
XML-RelaxNG-Compact-PXB-0.06
http://search.cpan.org/~mpg/XML-RelaxNG-Compact-PXB-0.06/
create perl XML (RelaxNG Compact) data binding API
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: Thu, 12 Jun 2008 01:17:49 +0200
From: swilting <john.swilting@wanadoo.fr>
Subject: Re: OT: please help me for my script
Message-Id: <48505d1d$0$898$ba4acef3@news.orange.fr>
Dan Rumney wrote:
> swilting wrote:
> [snip]
>>>
>>> Sneaky little bug that
>> error !!
>> not error syntaxic
>>
>> its lexical error
>>
>> not trool i am funny enrolment for perl
>
> Actually, I believe it's a semantic error (also known as a logic error).
do you use FILEHANDLE ? perharps ?
i not succes release with png random
ai text png
help me ? its very important !
its this funny trool to the program cgi
i do use html code into the perl code?
------------------------------
Date: Wed, 11 Jun 2008 19:27:50 -0400
From: Dan Rumney <danrumney@warpmail.net>
Subject: Re: OT: please help me for my script
Message-Id: <48505f56$0$31730$4c368faf@roadrunner.com>
swilting wrote:
[snip]
>
> do you use FILEHANDLE ? perharps ?
>
> i not succes release with png random
> ai text png
>
> help me ? its very important !
> its this funny trool to the program cgi
>
> i do use html code into the perl code?
Sorry John,
I can't understand what you're asking at all.
Are you using a program to translate to English?
------------------------------
Date: Thu, 12 Jun 2008 01:40:57 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: OT: please help me for my script
Message-Id: <ljv054lnmkalo5gqhvinbuasdmfnco6bah@4ax.com>
swilting <john.swilting@wanadoo.fr> wrote:
>the new script function well
>alse the png image is not view
>the png code is pretty read !!!
>and dont understood
I have absolutely no idea what you are talking about.
Could you repeat that in English, please?
jue
------------------------------
Date: Wed, 11 Jun 2008 22:56:20 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: sorting a hash / 2008-06-01
Message-Id: <48n5i5xrvi.ln2@carpet.zombinet>
Dave Saville <dave@nospam.deezee.org> wrote:
*SKIP*
> Sorry to jump in with another question but I have a very similar
> problem. I am processing a consolidated apache2 logfile. I have
> multiple virtual hosts. All I care about are the site, the page
> served, a counter and the date.
Piece of advice. The next time you'll would like to I<jump in> consider
stoling the thread. Otherwise your question can be left unanswered.
Because it wasn't seen.
*SKIP*
> I have tried various ideas I found by google but they all tend to be
> similar to this
Forget B<google>, use B<perldoc> instead.
> sub by_count
> {
> $urls{$site}{$b}[0] <=> $urls{$site}{$a}[0] or $a cmp $b;
> }
Hopefully Uri won't see that. I<$a> and I<$b> are special. However
only in context of B<sort>.
*SKIP*
> I would be grateful for any pointers.
If I guessed your problem right way, than:
print "$site $_ $urls{$site}{$_}[0] $urls{$site}{$_}[1]\n"
foreach(
sort { $urls{$site}{$a}[0] <=> $urls{$site}{$b}[0]; }
sort { $urls{$site}{$a}[1] <=> $urls{$site}{$b}[1]; }
keys %{$urls{$site}});
(Sorry for extra(?) parenthesis and semicolons; I'm not sure yet if
B<perl> would compile my intensions right.) Please note, that supposes
that dates are unix-epoched; otherwise you must do the comparision by
himself or pass it some other module.
--
Torvalds' goal for Linux is very simple: World Domination
------------------------------
Date: Thu, 12 Jun 2008 04:02:19 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: sorting a hash / 2008-06-01
Message-Id: <x7od6747y1.fsf@mail.sysarch.com>
>>>>> "EP" == Eric Pozharski <whynot@pozharski.name> writes:
EP> Dave Saville <dave@nospam.deezee.org> wrote:
EP> *SKIP*
>> Sorry to jump in with another question but I have a very similar
>> problem. I am processing a consolidated apache2 logfile. I have
>> multiple virtual hosts. All I care about are the site, the page
>> served, a counter and the date.
EP> Piece of advice. The next time you'll would like to I<jump in> consider
EP> stoling the thread. Otherwise your question can be left unanswered.
EP> Because it wasn't seen.
EP> *SKIP*
>> I have tried various ideas I found by google but they all tend to be
>> similar to this
EP> Forget B<google>, use B<perldoc> instead.
>> sub by_count
>> {
>> $urls{$site}{$b}[0] <=> $urls{$site}{$a}[0] or $a cmp $b;
>> }
EP> Hopefully Uri won't see that. I<$a> and I<$b> are special. However
EP> only in context of B<sort>.
i did. my eyes are bleeding!
>> I would be grateful for any pointers.
EP> If I guessed your problem right way, than:
EP> print "$site $_ $urls{$site}{$_}[0] $urls{$site}{$_}[1]\n"
EP> foreach(
EP> sort { $urls{$site}{$a}[0] <=> $urls{$site}{$b}[0]; }
EP> sort { $urls{$site}{$a}[1] <=> $urls{$site}{$b}[1]; }
EP> keys %{$urls{$site}});
are you (or the OP) trying to do a multilevel sort? it looks like yours
will work but it is unusual to do two sort passes. and it relies on the
sort to be stable (meaning equal keys stay in the same ordering post
sort). perl now uses a stable sort but earlier versions didn't. it is
not something you should depend upon.
and of course Sort::Maker makes this easy. (untested):
use Sort::Maker ;
my $sorter = make_sorter( 'ST', number => '$urls{$site}{$_}[0],
number => '$urls{$site}{$_}[1] ) ;
my @sorted = $sorter->( keys %{$urls{$site}} ) ;
and i don't know the data structure so there may be ways to improve
that.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 11 Jun 2008 21:46:49 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Time and again
Message-Id: <slrng513gp.ff6.tadmc@tadmc30.sbcglobal.net>
Bill H <bill@ts1000.us> wrote:
> On Jun 11, 10:34 am, nolo contendere <simon.c...@fmr.com> wrote:
>> On Jun 10, 5:27 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
>>
>> > Bill H <b...@ts1000.us> wrote:
>> > > If you are printing localtime() to a file so that it is readable and
>> > > know that you are going to want to sort it later, why not just do
>>
>> > > print qq~localtime()|time()~;
>>
>> > Did you try that code before posting it?
>>
>> > ...
>>
>> > I didn't think so.
>>
>> # ./try_time.pl
>> localtime()|time()#
>
> Actually no - my bad. I was trying to illustrate what I mean and used
> a very poor example of it.
Even poorer if it had called the functions rather than printing
the names of the functions.
It contains a race since it calls time() twice...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
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 1633
***************************************