[16845] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4257 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 06:10:30 2000

Date: Fri, 8 Sep 2000 03:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968407815-v9-i4257@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4257

Today's topics:
        Perl & NT <brianlk@pacific.net.hk>
    Re: perl + Postgres Question <troyr@vicnet.net.au>
    Re: perl book? <ihra@dlc.fi>
    Re: Regards CGI.pm (Gwyn Judd)
    Re: Stable sorting <bart.lateur@skynet.be>
    Re: The Heartbreak of Inscrutable Perl Code <stephenk@cc.gatech.edu>
    Re: The Heartbreak of Inscrutable Perl Code (Gwyn Judd)
    Re: The Heartbreak of Inscrutable Perl Code (Eric Bohlman)
    Re: The Heartbreak of Inscrutable Perl Code <abe@ztreet.demon.nl>
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? <bkennedy99@home.com>
    Re: use strict: why? <bkennedy99@home.com>
    Re: use strict: why? <bart.lateur@skynet.be>
        using "|" as plain text in scripts (perl win) <kmojar@bmjgroup.com>
        what is the best way to get the lastest line from a fil <fukai@asia.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 08 Sep 2000 14:48:53 +0800
From: Brian Leung <brianlk@pacific.net.hk>
Subject: Perl & NT
Message-Id: <39B88BD5.79F21814@pacific.net.hk>

Hello all,
Is it possible that someone can add user account by perl script in NT 4
or win 2000?
Thanks

--
Regards,

Brian Leung




------------------------------

Date: Fri, 8 Sep 2000 15:33:07 +1100
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: Re: perl + Postgres Question
Message-Id: <YZZt5.11557$cr3.329179@ozemail.com.au>

Thanks
I got the data out and back in safely

I done a select DISTINCT * from tablename into another table then delete
from tablename

then reinserted it


> "Troy Rasiah" <troyr@vicnet.net.au> wrote:
> >
> > Hi Guys..this is more of a sql question than anything else but i'm
hopeing
> > someone can help me answer this
> >
> > Somehow in my Postgres database I have dulplicate records...ie having
the
> > same primary key..I'm guessing something went wrong when i restored from
a
> > backup
> >
> > Does anyone know a safe way of removing the duplicates?
> >
> > ie i can't say delete from tablename where id=26 if there are 2 records
> > which have the id of 26
>
> That sounds like a nasty problem.  I'm not an expert in this area,
> but what I would try to do is save the record data, delete the
> record(s), and then re-insert.  If you have identical records down
> to the primary key I would imagine that from an SQL point of view
> there's no way to distinguish between the records.
>
>




------------------------------

Date: Fri, 08 Sep 2000 08:25:25 GMT
From: Jussi Josefsson <ihra@dlc.fi>
Subject: Re: perl book?
Message-Id: <39B8A27F.464F6B4D@dlc.fi>

> Anyone use or teach themselves with Learning Perl? Did you have a
> better experience than my coworkers?

I think mostly it is ok for reference only, as I learned Perl much
better with Perl Cookbook. That's it, from the top to the down. Best way
to learn is to have (a huge) problem and solve it piece by piece.
Software engineers tend to call it waterfall or spiral method.

And "Perl in nutshell" is excellent table-top reference, even better is
"Perl bookshelf" (Perl in nutshell is included as a hardcopy with it),
which includes Learning Perl, Perl in nutshell, Advanced Perl
programming, Perl Cookbook and Perl for Win32. These are from 
O'reilly. It is my opinion, but overally their books seems to satisfy my
taste pretty well.

Only book I am missing is good book about CGI.pm (more advanced than
Official guide to CGI.pm by Lincoln Stein) or even more one that
includes tips and tricks using CGI.pm (kind of CGI Cookbook, anyone?).

Jussi "Ihra" Josefsson


------------------------------

Date: Fri, 08 Sep 2000 05:01:06 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Regards CGI.pm
Message-Id: <slrn8rgskf.6gp.tjla@thislove.dyndns.org>

I was shocked! How could Ken <kenn_mar@hotmail.com>
say such a terrible thing:
>
>
>
>> You'll need to specify absolute paths for your images.  Your problem is
>> that when you use the bare names, the browser interprets them as relative
>> to your script's name.
>
>I've done that but to no avail. Eg. I've tried "C:\\www\gifs\" in which case
>CGI.pm prints out C:\www\gifs. I've tried "..\www\gifs\" and still didn't
>worked. Any other alternatives?

Well you don't need to do the paths with '\' as the seperator as perl
will translate them for you. Especially seeing as how '\' in a
double-quoted string is interpolated as escaping the next character.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The voyage of discovery is not in seeking new landscapes but in having
new eyes.

		-- Marcel Proust


------------------------------

Date: Fri, 08 Sep 2000 08:36:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Stable sorting
Message-Id: <i09hrs883qp0tmi0v01n942m4njas6bi3v@4ax.com>

Alan Barclay wrote:

>If you want to have the best possible performance, then you should
>be reading Knuth, Art of Computer Programming, Volume 3, and choose an
>appropriate algorythm for your data. Of course, you probably shouldn't
>be programming in perl, any efficencies you save by selecting the
>sort will be lost by the speed of perl compared to the built in
>sort.

No, what the OP was asking (I think), is for a possibility to choose the
algorithm of the built-in sort. In his case, the selection is very
simple-minded: requirement of a stable sort, or not; assuming that a
non-stable sort would be faster.

I would never suggest that hand created sort code in Perl would be
faster than the built-in sort; not for any practical (i.e. smallish)
data sets. Asymptotes don't count.

-- 
	Bart.


------------------------------

Date: Fri, 08 Sep 2000 00:16:38 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <39B86826.DE21428C@cc.gatech.edu>

Abigail wrote:

> Avast (avast@hortonsbay.com) wrote on MMDLXV September MCMXCIII in
> <URL:news:39b83211.32895141@news.accesstoledo.com>:
> __
> __ Yeah, but the JAPHs are fun to run.  I especially like the one of
> __ Abigail's that prints "Just Another Perl Hacker" backwards and then
> __ reverses it slowly letter by letter.  Pretty cool!
>
> Never wrote such a one. I think you are confused with the one that performs
> a bubble sort to put the letters in the correct position. ;-)
>

in news:slrn8qoviq.bbg.abigail@alexandra.foad.org under the thread "png/gif
format".
Looks like the one Avast was referring to.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




------------------------------

Date: Fri, 08 Sep 2000 04:41:50 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <slrn8rgrgc.6gp.tjla@thislove.dyndns.org>

I was shocked! How could Abigail <abigail@foad.org>
say such a terrible thing:
>Malcolm Dew-Jones (yf110@vtn1.victoria.tc.ca) wrote on MMDLXIV September
>MCMXCIII in <URL:news:39b8168d@news.victoria.tc.ca>:
>"" 
>"" Pasal programmers claim that I = I + 1 is clearer than I++;
>
>Really? A strange breed of Pascal programmers. I'd think they prefer
>
>    I = inc (I);

Wouldn't that be I = IncrementANumber(I);

?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
To err is human, to forgive, beyond the scope of the Operating System.


------------------------------

Date: 8 Sep 2000 06:10:12 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <8p9vs4$264$3@slb3.atl.mindspring.net>

Avast (avast@hortonsbay.com) wrote:
: Just wanted to thank everyone who responed to my message.  Learning
: this stuff is certainly frustrating sometimes as I'm sure you'd all
: agree, but having you fine folks on the other end certainly makes the
: journey interesting.

A good resource for learning common Perl idioms is Joseph Hall's 
_Effective Perl Programming_.



------------------------------

Date: Fri, 08 Sep 2000 11:43:46 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <c1dhrscq2knira5ure8ckbm4ru9lcgq1jb@4ax.com>

On 08 Sep 2000 00:32:06 GMT, abigail@foad.org (Abigail) wrote:

> Malcolm Dew-Jones (yf110@vtn1.victoria.tc.ca) wrote on MMDLXIV September
> MCMXCIII in <URL:news:39b8168d@news.victoria.tc.ca>:
> "" 
> "" Pasal programmers claim that I = I + 1 is clearer than I++;
> 
> Really? A strange breed of Pascal programmers. I'd think they prefer
> 
>     I = inc (I);

They might, but most compilers would disagree with them.

	I := inc(I);

-- 
Good luck,
Abe


------------------------------

Date: Thu, 07 Sep 2000 21:50:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B87009.7D4B4B49@stomp.stomp.tokyo>

Tim Hammerquist wrote:
 
> On Tue, 05 Sep 2000 15:23:49 GMT, Ben Kennedy <bkennedy99@home.com> wrote:
> > Considering that lexical variables are faster than global variables
 
> This didn't sound right to me.  I remember reading that lexical (my)
> variables are faster than variables defined with the local keyword, but
> never heard that lexicals are faster than globals.  So I did research:
 
> : Benchmark: timing 100000000 iterations of global, lexical...
> :    global: 170 wallclock secs (162.30 usr +  0.24 sys = 162.54 CPU)
> :   lexical: 180 wallclock secs (174.32 usr + -0.03 sys = 174.29 CPU)


Good logic behind globals being faster and, there are a few
additional notions to consider.

Globals are quicker because they are stashed into an array
which perl core can access easily. Not sure on 'local' style
variables. I suppose local variables might be slightly faster
than 'my' type variables. I would guess not enough to make
a real difference.

Use of 'my' type variables invokes a lot of extra activity
for perl core. In this case, a Perl programmer needs to be
experienced enough to wisely weigh when a trade off in speed
is worth extra memory being released by my declarations and,
know when use of my declarations is detrimental to a program.

Another notion to consider is you ran tests on one of each
type of variable. I just glanced at one of my larger programs.
I use seventy-three globals and, guessing, three times as many
my declarations. Your test results would be quite different
and show a dramatic difference in speed if you tested under
realistic conditions; multitudes of globals and my variables.

Naturally, speed of a script is also affected by how much
'activity' takes place for globals and, the same for my
variables. Inherently, a good programmer will use global
variables with lots of subroutines manipulating the same
data sets. Equally inherent, a good programmer will use
my declarations for extremely localized manipulations.

Your tests are valid but only hint at a much bigger picture,
a rather different picture. Use of globals when possible,
leads to a much faster script than use of all my declarations.
This is good logic and, clearly substantiated by testing.

An inference can be drawn, a notion I suggest often. Those
who demand and command a programmer always use 'strict' and
always use 'my' declarations, are very poor programmers
whose advice should be ignored.

What I have said many times, much to the annoyance of those
poor programmers, I will say again.

Use of pragma hints, use of strict, use of modules and use
of my declarations, all should be used wisely and not
proposed as an anal retentive must do absolute rule.

Your tests results do show how dead wrong are these AR programmers.


Godzilla!
--
print "http://3483852801/%7e%63%61ll%67i%72l";


------------------------------

Date: Fri, 08 Sep 2000 07:25:15 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: use strict: why?
Message-Id: <vv0u5.15714$AW2.202270@news1.rdc2.pa.home.com>


"Tim Hammerquist" <tim@degree.ath.cx> wrote in message
news:slrn8rge5m.26k.tim@degree.ath.cx...
> On Tue, 05 Sep 2000 15:23:49 GMT, Ben Kennedy <bkennedy99@home.com> wrote:
> > Considering that lexical variables are faster than global variables
>
> This didn't sound right to me.  I remember reading that lexical (my)
> variables are faster than variables defined with the local keyword, but
> never heard that lexicals are faster than globals.

I was really talking about it in terms of making variables private, but I am
curious about those results.  I'm not an internals expert, but from what
I've read, global variables are stored in the package's symbol table, while
lexical values are stored in a scratchpad dedicated to that particular
block.  Accessing this scratchpad should be faster in tight loops - I tried:

use Benchmark;

sub global_test {
 for ($i = 1;$i < 10_000_000;$i++) {

 }
}

sub lexical_test {
  for (my $i = 1;$i < 10_000_000;$i++) {

 }
}

timethese(1, {
  lexical => \&lexical_test,
  global => \&global_test,
 });

And got pro-lexical results - probably because the scratchpad is empty, and
the symbol table is cluttered.  But in the long run, I guess it doesn't
matter.  Though for some reason it seems more artisic to keep the symbol
table as clean.

--Ben Kennedy





------------------------------

Date: Fri, 08 Sep 2000 07:49:15 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: use strict: why?
Message-Id: <%R0u5.15761$AW2.202295@news1.rdc2.pa.home.com>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:39B87009.7D4B4B49@stomp.stomp.tokyo...
> Tim Hammerquist wrote:
>
> > On Tue, 05 Sep 2000 15:23:49 GMT, Ben Kennedy <bkennedy99@home.com>
wrote:

> Globals are quicker because they are stashed into an array
> which perl core can access easily. Not sure on 'local' style
> variables. I suppose local variables might be slightly faster
> than 'my' type variables. I would guess not enough to make
> a real difference.

You can only use local on global variables.  Variables that have been
local()'ized are still global variables, ironically - perl temporarily
stores the old value, and restores it when the block ends.  'my' variables
are faster because the are created from scratch and stored in a truly local
space, and there is no overhead for saving and restoring another value.

> Your tests are valid but only hint at a much bigger picture,
> a rather different picture. Use of globals when possible,
> leads to a much faster script than use of all my declarations.
> This is good logic and, clearly substantiated by testing.

The bigger picture isn't speed IMO, but a mix of speed, memory consumption,
and maintainablity.  Code written with a generous use of globals is much
easier to break and will have a bloated symbol table.  Code written with a
generous amount of 'my's tends to be more self-contained, and is easier to
integrate with other programs.

> Use of pragma hints, use of strict, use of modules and use
> of my declarations, all should be used wisely and not
> proposed as an anal retentive must do absolute rule.

A signifigant portion of questions in this group would not have been asked
if the OP had been using strict or warnings.  But a person posts broken code
here, and they haven't tried it with strict or warnings, then they shouldn't
be doing it.  There is nothing wrong with encouraging new users to use all
the diagnostic tools available to them.  I don't think it should be an
absolute rule for all programming, but it should be an absolute rule if you
are seeking help from people on this group.

--Ben Kennedy




------------------------------

Date: Fri, 08 Sep 2000 08:31:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: use strict: why?
Message-Id: <rr8hrsgd06ke9boms6dbicpbid8u8nb7gs@4ax.com>

Tim Hammerquist wrote:

>I never asked why people recommend it. Especially in a newsgroup like 
>this, it's use is obvious.  I asked why it's absence in a script is
>labeled as an error.

It's a big aid in debugging. If people ask questions here because they
are having troubles with their code, and they're not using strict, then
they haven't depleted their debugging options yet.


-- 
	Bart.


------------------------------

Date: Fri, 08 Sep 2000 10:17:19 +0100
From: Kourosh A Mojar <kmojar@bmjgroup.com>
Subject: using "|" as plain text in scripts (perl win)
Message-Id: <39B8AE9F.31140C02@bmjgroup.com>

dear all,

im been trying to use "|" (pipe?) as pain text for creating flat
database files. but does not allow my scripts to work properly. ive
tried \| to try and cancel its command features but unsuccessful. i
haven't found any examples in books and was hoping someone could give me
a quick fix. can any one advise me on what is the best way to do this.

thanking you in advance and for your kind attention,

kourosh a mojar


------------------------------

Date: Fri, 08 Sep 2000 11:33:22 +0200
From: Fu Kai <fukai@asia.com>
Subject: what is the best way to get the lastest line from a file?
Message-Id: <39B8B262.AB8214A9@asia.com>

hi,
I want to only get the lastest line from a *HUGE* plain text file(about
20M),
and i think it is not a efficient way to catch it just read lines one by
one,
so what is the best way to do it? and how?

Any help is appreciated!!

--
Kai





------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4257
**************************************


home help back first fref pref prev next nref lref last post