[29644] in Perl-Users-Digest
Perl-Users Digest, Issue: 888 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 28 14:09:45 2007
Date: Fri, 28 Sep 2007 11: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 Fri, 28 Sep 2007 Volume: 11 Number: 888
Today's topics:
Re: [OT] optimal vs. optimized <cwilbur@chromatico.net>
Re: FAQ 4.51 How do I permute N elements of a list? <brian.d.foy@gmail.com>
Re: How to get some specify lines in a block of a file? <ulmai@gmx.de>
Perl compiler for MAC and Linux? <bill@ts1000.us>
Re: Perl compiler for MAC and Linux? <ben@morrow.me.uk>
Read attachment <didlep@hotmail.com>
Re: Read attachment <glex_no-spam@qwest-spam-no.invalid>
Re: Small doubt in perl <ben@morrow.me.uk>
Re: Small doubt in perl <bik.mido@tiscalinet.it>
Sort and remove duplicates <webmaster@valleywebnet.com>
Re: Sort and remove duplicates (Greg Bacon)
Re: Sort and remove duplicates <webmaster@valleywebnet.com>
Re: Sort and remove duplicates <glennj@ncf.ca>
Re: Sort and remove duplicates <ben@morrow.me.uk>
Re: Sort and remove duplicates (Greg Bacon)
Re: string concatentation vs. interpolation: which one <tadmc@seesig.invalid>
Re: string concatentation vs. interpolation: which one (Greg Bacon)
Re: string concatentation vs. interpolation: which one <ben@morrow.me.uk>
Re: string concatentation vs. interpolation: which one <cwilbur@chromatico.net>
Trying to start a perl script as Windows Service <dn.perl@gmail.com>
Re: why are references so slow ? <tzz@lifelogs.com>
Re: why are references so slow ? <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Sep 2007 12:29:26 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: [OT] optimal vs. optimized
Message-Id: <87k5qakb2x.fsf@mithril.chromatico.net>
>>>>> "bdf" == brian d foy <brian.d.foy@gmail.com> writes:
bdf> I like "optimal" still, but people have to realize that it's
bdf> a relative and subjective term based on the assumptions and
bdf> goals of the person using it. It's not meaningless although
bdf> it is often used without context and with the implicit
bdf> asumptions that everyone wants the same thing. :)
I'm not sure it's subjective, and I certainly don't think it's
meaningless; I think in common usage it's vague, and I agree that the
context is almost always incorrectly implied or inferred.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Fri, 28 Sep 2007 12:24:27 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.51 How do I permute N elements of a list?
Message-Id: <280920071224273470%brian.d.foy@gmail.com>
In article <vekpf35i77k5407524du3fkup5rgdje32n@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> On Wed, 19 Sep 2007 09:09:45 -0700, brian d foy
> <brian.d.foy@gmail.com> wrote:
>
> >> If there's some interest in this I may try to concoct a patch to the
> >> faq entry.
> >
> >Yes, please do. You can post it here and I should find it.
>
> Here it is, HTH:
Added, thanks, :)
------------------------------
Date: Fri, 28 Sep 2007 15:09:44 +0200
From: Jan Pluntke <ulmai@gmx.de>
Subject: Re: How to get some specify lines in a block of a file?
Message-Id: <uwsubey1z.fsf@ID-18539.user.dfncis.de>
dolphin <jdxyw2004@gmail.com> writes:
> I have a question now,How to get some specify lines in a block of a
> file?
[...]
> I just want to get some specify lines in the block of ABC{ }.
> What should I do?
If I understand your question correctly,
perldoc -q lines between patterns
might provide an answer.
Regards,
Jan
------------------------------
Date: Fri, 28 Sep 2007 05:44:32 -0700
From: Bill H <bill@ts1000.us>
Subject: Perl compiler for MAC and Linux?
Message-Id: <1190983472.050296.42280@n39g2000hsh.googlegroups.com>
Does anyone know of any perl compilers that would create a stand alone
program for perl for the MAC and Linux? I have Perl2Exe for the PC but
haven't seen one for the MAC or Linux.
Thanks,
Bill H
------------------------------
Date: Fri, 28 Sep 2007 16:30:31 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perl compiler for MAC and Linux?
Message-Id: <n9jvs4-ho5.ln1@osiris.mauzo.dyndns.org>
Quoth Bill H <bill@ts1000.us>:
> Does anyone know of any perl compilers that would create a stand alone
> program for perl for the MAC and Linux? I have Perl2Exe for the PC but
> haven't seen one for the MAC or Linux.
PAR will create standalone executables for Mac OS X and Linux. I don't
know if it works with Mac OS Classic, but you likely don't care.
Ben
------------------------------
Date: Fri, 28 Sep 2007 15:51:22 -0000
From: "N@p0" <didlep@hotmail.com>
Subject: Read attachment
Message-Id: <1190994682.330952.73160@d55g2000hsg.googlegroups.com>
Hi,
Please, I wich read some mails with POP or IMAP protocol and extract
attachment from these. How can i do this in perl (of course) ?
Thanks,
------------------------------
Date: Fri, 28 Sep 2007 10:53:21 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Read attachment
Message-Id: <46fd2371$0$498$815e3792@news.qwest.net>
N@p0 wrote:
> Hi,
>
> Please, I wich read some mails with POP or IMAP protocol and extract
> attachment from these. How can i do this in perl (of course) ?
There are a lot of modules at CPAN, of course.
http://search.cpan.org/
------------------------------
Date: Fri, 28 Sep 2007 16:19:24 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Small doubt in perl
Message-Id: <skivs4-ho5.ln1@osiris.mauzo.dyndns.org>
Quoth Michele Dondi <bik.mido@tiscalinet.it>:
> On Wed, 26 Sep 2007 22:55:59 -0700, anil <anilkumar.iitm@gmail.com>
> wrote:
>
> >system("sample.sh");
> >system("java test");
> >
> >In the "sample.sh" i have set some environmental variables, but the
> >environment variables which are set in the sample.sh are not used by
> >the java pgm.
> >
> >Is there any other way to achieve this functionality?
>
> system qw/sh -c/ => 'sample.sh; java test';
This won't work. sample.sh is still run as a subprocess of the shell.
You need to locate the shell used for sample.sh (I'll assume /bin/sh),
and run
system '/bin/sh', -c => '. sample.sh; java test';
Note the '.', which makes the shell run the script in the same process.
It may be better to use
system '/bin/sh', -c => '. sample.sh; exec java test';
which will save a fork.
Ben
------------------------------
Date: Fri, 28 Sep 2007 18:03:15 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Small doubt in perl
Message-Id: <id9qf3dmi80l2c1fr53v00loadmri6s3gi@4ax.com>
On Fri, 28 Sep 2007 16:19:24 +0100, Ben Morrow <ben@morrow.me.uk>
wrote:
>> system qw/sh -c/ => 'sample.sh; java test';
>
>This won't work. sample.sh is still run as a subprocess of the shell.
>You need to locate the shell used for sample.sh (I'll assume /bin/sh),
>and run
>
> system '/bin/sh', -c => '. sample.sh; java test';
>
>Note the '.', which makes the shell run the script in the same process.
D'Oh! It's true...
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: Fri, 28 Sep 2007 06:10:54 -0700
From: JimJx <webmaster@valleywebnet.com>
Subject: Sort and remove duplicates
Message-Id: <1190985054.159629.205280@22g2000hsm.googlegroups.com>
Hi everyone,
Got what should be an easy problem.
I have a db (MySQL) that I need to sort on the first field and remove
dups from.
For example, let's say I have Red,1,2,3,4,5 and Blue,1,2,3,4,5 and
Green,1,2,3,4,5 and Green,2,2,2,2,2
How can I come out with Blue,1,2,3,4,5;Green,1,2,3,4,5;Red,1,2,3,4,5??
I know that there is a simple way to do this but my brain is not
functioning right now.
Thanks!
Jim
------------------------------
Date: Fri, 28 Sep 2007 14:33:55 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Sort and remove duplicates
Message-Id: <13fq46jd0fuvr62@corp.supernews.com>
In article <1190985054.159629.205280@22g2000hsm.googlegroups.com>,
JimJx <webmaster@valleywebnet.com> wrote:
: I have a db (MySQL) that I need to sort on the first field and
: remove dups from.
:
: For example, let's say I have Red,1,2,3,4,5 and Blue,1,2,3,4,5
: and Green,1,2,3,4,5 and Green,2,2,2,2,2
:
: How can I come out with Blue,1,2,3,4,5;Green,1,2,3,4,5;
: Red,1,2,3,4,5??
Why does the Green row get 1,2,3,4,5 on the output?
Greg
--
The list of stable paper currencies built by central bankers is as
short as the list of stable democracies built by armed invaders.
-- Bill Bonner
------------------------------
Date: Fri, 28 Sep 2007 08:00:53 -0700
From: JimJx <webmaster@valleywebnet.com>
Subject: Re: Sort and remove duplicates
Message-Id: <1190991653.009964.230380@y42g2000hsy.googlegroups.com>
On Sep 28, 10:33 am, gba...@hiwaay.net (Greg Bacon) wrote:
> In article <1190985054.159629.205...@22g2000hsm.googlegroups.com>,
> JimJx <webmas...@valleywebnet.com> wrote:
>
> : I have a db (MySQL) that I need to sort on the first field and
> : remove dups from.
> :
> : For example, let's say I have Red,1,2,3,4,5 and Blue,1,2,3,4,5
> : and Green,1,2,3,4,5 and Green,2,2,2,2,2
> :
> : How can I come out with Blue,1,2,3,4,5;Green,1,2,3,4,5;
> : Red,1,2,3,4,5??
>
> Why does the Green row get 1,2,3,4,5 on the output?
>
> Greg
> --
> The list of stable paper currencies built by central bankers is as
> short as the list of stable democracies built by armed invaders.
> -- Bill Bonner
Because Green would be a dup and 1,2,3,4,5 comes before 2,2,3,4,5
------------------------------
Date: 28 Sep 2007 15:21:21 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Sort and remove duplicates
Message-Id: <slrnffq6vi.db8.glennj@smeagol.ncf.ca>
At 2007-09-28 09:10AM, "JimJx" wrote:
> Hi everyone,
>
> Got what should be an easy problem.
>
> I have a db (MySQL) that I need to sort on the first field and remove
> dups from.
>
> For example, let's say I have Red,1,2,3,4,5 and Blue,1,2,3,4,5 and
> Green,1,2,3,4,5 and Green,2,2,2,2,2
>
> How can I come out with Blue,1,2,3,4,5;Green,1,2,3,4,5;Red,1,2,3,4,5??
my %data;
while (<DATA>) {
my $field1 = (split ',')[0];
$data{$field1} = $_ unless exists $data{$field1};
}
my @non_dups = values %data;
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
------------------------------
Date: Fri, 28 Sep 2007 16:32:40 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Sort and remove duplicates
Message-Id: <odjvs4-ho5.ln1@osiris.mauzo.dyndns.org>
Quoth JimJx <webmaster@valleywebnet.com>:
> Hi everyone,
>
> Got what should be an easy problem.
>
> I have a db (MySQL) that I need to sort on the first field and remove
> dups from.
>
> For example, let's say I have Red,1,2,3,4,5 and Blue,1,2,3,4,5 and
> Green,1,2,3,4,5 and Green,2,2,2,2,2
>
> How can I come out with Blue,1,2,3,4,5;Green,1,2,3,4,5;Red,1,2,3,4,5??
>
> I know that there is a simple way to do this but my brain is not
> functioning right now.
perldoc DBI
perldoc -q duplicate
(possibly perldoc -f sort as well)
When you've had a go, post your code and we'll help you fix it.
Ben
------------------------------
Date: Fri, 28 Sep 2007 16:02:37 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Sort and remove duplicates
Message-Id: <13fq9cthmjfds35@corp.supernews.com>
In article <1190991653.009964.230380@y42g2000hsy.googlegroups.com>,
JimJx <webmaster@valleywebnet.com> wrote:
: On Sep 28, 10:33 am, gba...@hiwaay.net (Greg Bacon) wrote:
:
: > Why does the Green row get 1,2,3,4,5 on the output?
:
: Because Green would be a dup and 1,2,3,4,5 comes before 2,2,3,4,5
Ah. I thought you wanted to remove duplicates in the other columns
too. (The five 2s threw me off.)
Glenn Jackman's answer is what you want.
Greg
--
To admit that labor needs protection is to acknowledge its inferiority.
-- Henry George, Protection or Free Trade
------------------------------
Date: Fri, 28 Sep 2007 11:12:21 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <slrnffpo7m.55p.tadmc@tadmc30.sbcglobal.net>
rihad <rihad@mail.ru> wrote:
> On Sep 28, 2:03 am, brian d foy <brian.d....@gmail.com> wrote:
>> In article <1190824931.665621.151...@50g2000hsm.googlegroups.com>,
>>
>> rihad <ri...@mail.ru> wrote:
>> > Programming Perl (The Camel Book) states that "String concatenation is
>> > also implied by the interpolation that happens in double-quoted
>> > strings."
>> > Can someone experienced in Perl source code confirm that they are
>> > identical in terms of raw speed and memory use or not?
>>
>> When you start looking at the speed of things like this and actaully
>> caring about the answer, you'll probably find that Perl is not the
>> right tool for the job. Perl is really fast, but if this sort of
>> operation is too slow for you, then the bigger tasks in Perl, uch as
>> using a module, will just kill your performance (relatively).
> Ok this seems to be coming from the innards of great developing
> experience.
Here's some more:
http://en.wikipedia.org/wiki/Optimization_(computer_science)#When_to_optimize
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 28 Sep 2007 14:38:42 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <13fq4fi24olt63b@corp.supernews.com>
In article <1190824931.665621.151990@50g2000hsm.googlegroups.com>,
rihad <rihad@mail.ru> wrote:
: print $a . ' is equal to ' . $b . ".\n"; # dot operator
: print "$a is equal to $b.\n"; # interpolation
These compile to the same ppcode.
Greg
--
Not a place upon earth might be so happy as America. Her situation is
remote from all the wrangling world and she has nothing to do but trade
with them.
-- Thomas Paine
------------------------------
Date: Fri, 28 Sep 2007 16:28:35 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <36jvs4-ho5.ln1@osiris.mauzo.dyndns.org>
Quoth rihad <rihad@mail.ru>:
>
> Besides, interpolation is almost always more legible than
> concatenation,
See also http://blog.plover.com/prs/nyc.html .
> > Before anyone gets too concerned about small details like this
> > (especially when Perl is not constrained to implement them in any way
> > and the next release of Perl might do it differently), try profiling
> > the application that you are concerned about. You'll find easier and
> > slower things to fix and worry about :)
>
> Ok this seems to be coming from the innards of great developing
> experience. Again, the reason I asked is based on my strive for
> perfection, not that I was counting on an answer here to make more
> money or anything.
>
> /Here I reread what's been written, and .../
>
> Still... why shouldn't Perl (or language Foo) programmers care about
> efficiency if OS programmers _do_ care?
The point is, you should care when, and only when, it matters. Worrying
about micro-optimization without having profiled first is always a waste
of time, and only leads to writing illegible code.
Ben
------------------------------
Date: 28 Sep 2007 12:40:11 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <87fy0ykal0.fsf@mithril.chromatico.net>
>>>>> "r" == rihad <rihad@mail.ru> writes:
r> Still... why shouldn't Perl (or language Foo) programmers care
r> about efficiency if OS programmers _do_ care?
Perl programmers care about efficiency in the same way that OS
programmers care about efficiency: it's one of a set of things to
worry about (which include expressiveness, readability,
maintainability, portability), and tradeoffs among them need to be
carefully balanced. What suits one project won't suit another.
The Linux kernel isn't written in C because C is inherently more
efficient than any other language, for instance; it's written in C
because C offers the tradeoff between efficiency, maintainability, and
control that is closest to what they need. Perl puts a lot more
emphasis on programmer time than computer time, which is not the right
solution for operating systems (which are written once and run many
thousands of times), but is the right solution for one-off scripts,
custom work with small teams, and other situations that are not likely
to be CPU-bound.
The right answer for performance tuning in Perl is the same as the
right answer for development in C: write the @#$% thing, then profile
it and fix the parts that are too slow. You get the biggest win from
choosing the right data structure and the right algorithm; after that
it's all rapidly diminishing returns.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Fri, 28 Sep 2007 16:45:54 -0000
From: "dn.perl@gmail.com" <dn.perl@gmail.com>
Subject: Trying to start a perl script as Windows Service
Message-Id: <1190997954.878545.172850@w3g2000hsg.googlegroups.com>
I want to run a perl script which will continue running on Windows XP
even after I log off, the way nohup works in Unix. A recommended way
of doing it is to run the application as Windows Service. Accordingly
I wrote a test script (myscript.pl), which prints a line every 10
seconds in an infinite loop :
Time is 2007-09-27 16:22:25
Time is 2007-09-27 16:22:35
Time is 2007-09-27 16:22:45
I created a service for the perl script. When I start the service, it
stops immediately.
The message is : The print_tstamp service on local computer started
and then stopped. Some services stop automatically if they have no
work to do, for example, the Performance Logs and Alerts service.
Any suggestions, please?
------------------------------
Date: Fri, 28 Sep 2007 11:05:35 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: why are references so slow ?
Message-Id: <m2sl4yepww.fsf@lifelogs.com>
On 28 Sep 2007 09:35:24 GMT all mail refused <elvis-85363@notatla.org.uk> wrote:
amr> On 2007-09-28, sln@netherlands.co <sln@netherlands.co> wrote:
>> On Wed, 26 Sep 2007 04:49:19 +0200, Daniel Dünker <dduenker@uni-koblenz.de> wrote:
>>> So, should i throw away all the parameters and just use global variables to get rid of referencing and dereferencing ?
>>
>> You should use nothing BUT global variables. Throw away subroutine parameters alltogether!
amr> Precompute all your programs and then for each situation run eithr /bin/true or /bin/false.
You might as well just write Quantum::Superpositions one-liners.
Ted
------------------------------
Date: Fri, 28 Sep 2007 17:25:50 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: why are references so slow ?
Message-Id: <ehmvs4-6v6.ln1@osiris.mauzo.dyndns.org>
Quoth Ted Zlatanov <tzz@lifelogs.com>:
> On 28 Sep 2007 09:35:24 GMT all mail refused
> <elvis-85363@notatla.org.uk> wrote:
>
> amr> On 2007-09-28, sln@netherlands.co <sln@netherlands.co> wrote:
> >> On Wed, 26 Sep 2007 04:49:19 +0200, Daniel Dünker
> <dduenker@uni-koblenz.de> wrote:
>
> >>> So, should i throw away all the parameters and just use global
> variables to get rid of referencing and dereferencing ?
> >>
> >> You should use nothing BUT global variables. Throw away subroutine
> parameters alltogether!
>
> amr> Precompute all your programs and then for each situation run eithr
> /bin/true or /bin/false.
>
> You might as well just write Quantum::Superpositions one-liners.
I'm not sure that would help... I'm fairly sure Acme::HaltingProblem
would be required as well :).
Ben
------------------------------
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 888
**************************************