[16320] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3732 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 11:18:30 2000

Date: Tue, 18 Jul 2000 08:18:07 -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: <963933487-v9-i3732@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 18 Jul 2000     Volume: 9 Number: 3732

Today's topics:
        Suggestion for syntax change (Keith G. Murphy)
    Re: Suggestion for syntax change <gellyfish@gellyfish.com>
    Re: Suggestion for syntax change (Jakob Schmidt)
    Re: Suggestion for syntax change (Larry Rosler)
    Re: Suggestion for syntax change (jason)
    Re: Suggestion for syntax change (jason)
    Re: Suggestion for syntax change (Jakob Schmidt)
    Re: Suggestion for syntax change (Bart Lateur)
    Re: telephone answering machine (Abigail)
        Testing and debuging scripts locally (EM)
    Re: Testing and debuging scripts locally (jason)
    Re: Testing and debuging scripts locally (Homer)
    Re: Testing and debuging scripts locally (jason)
    Re: Testing and debuging scripts locally (Eric Bohlman)
    Re: Testing and debuging scripts locally (John)
    Re: Testing and debuging scripts locally (Jonathan Stowe)
    Re: The newbie question (Godzilla!)
    Re: The newbie question (Godzilla!)
    Re: The problem of two Submit buttons (Philip Lees)
    Re: The problem of two Submit buttons (Larry Rosler)
    Re: This software is worth to try.... <gellyfish@gellyfish.com>
    Re: Time in mili-seconds (Tad McClellan)
        To Schwartz or not to Schwartz? (Michael Fischer)
    Re: To Schwartz or not to Schwartz? (Larry Rosler)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 17 Jul 2000 22:00:02 GMT
From: keithmur@mindspring.com.bbs@openbazaar.net (Keith G. Murphy)
Subject: Suggestion for syntax change
Message-Id: <3bRQg3$THW@openbazaar.net>

In the following chunk of code:

my @list = qw(apple boy cow);
print $list[0] . "\n";
print $list[2] . "\n";
print join(',', @list[0..2]) . "\n";
print $list[0] . "\n";
print $list[-1] . "\n";
print join(@list[0..-1]) . "\n";

outputting:

apple
cow
apple,boy,cow
apple
cow
(blank line)

wouldn't it make more sense if the last line were:

apple,boy,cow

?

I.e., letting you use the negative subscripts (meaning distance from end
of the string) inside a slice range might be rather nice.


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

Date: Tue, 18 Jul 2000 10:55:11 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Suggestion for syntax change
Message-Id: <jIWc5.326$Px6.32111@news.dircon.co.uk>

On Mon, 17 Jul 2000 17:01:37 -0500, Keith G. Murphy Wrote:
> In the following chunk of code:
> 
> my @list = qw(apple boy cow);
> print $list[0] . "\n";
> print $list[2] . "\n";
> print join(',', @list[0..2]) . "\n";
> print $list[0] . "\n";
> print $list[-1] . "\n";
> print join(@list[0..-1]) . "\n";
> 
> outputting:
> 
> apple
> cow
> apple,boy,cow
> apple
> cow
> (blank line)
> 
> wouldn't it make more sense if the last line were:
> 
> apple,boy,cow
> 
> ?
> 
> I.e., letting you use the negative subscripts (meaning distance from end
> of the string) inside a slice range might be rather nice.

Then you would have 'boyapplecow' in this case ....


/J\


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

Date: 17 Jul 2000 22:40:03 GMT
From: sumus@aut.dk.bbs@openbazaar.net (Jakob Schmidt)
Subject: Re: Suggestion for syntax change
Message-Id: <3bRRi3$U5r@openbazaar.net>

"Keith G. Murphy" <keithmur@mindspring.com> writes:

> In the following chunk of code:
[...]
> print join(@list[0..-1]) . "\n";
>
> outputting:
[...]
> (blank line)
>
> wouldn't it make more sense if the last line were:
>
> apple,boy,cow

You are aware of course that the .. is an operator in it's own right and not
specifically connected with the indexing of arrays?

Your wish would require that the .. operator behaved in a different manner
when it finds itself used in array indexing than in other contexts. Isn't
that a bit... erm... ugly?

--
Jakob


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

Date: 17 Jul 2000 22:40:03 GMT
From: lr@hpl.hp.com.bbs@openbazaar.net (Larry Rosler)
Subject: Re: Suggestion for syntax change
Message-Id: <3bRRi6$UHm@openbazaar.net>

In article <39738240.AEA38FF1@mindspring.com> on Mon, 17 Jul 2000
17:01:37 -0500, Keith G. Murphy <keithmur@mindspring.com> says...
+ In the following chunk of code:
+
+ my @list = qw(apple boy cow);
+ print $list[0] . "\n";
+ print $list[2] . "\n";
+ print join(',', @list[0..2]) . "\n";
+ print $list[0] . "\n";
+ print $list[-1] . "\n";
+ print join(@list[0..-1]) . "\n";
+
+ outputting:
+
+ apple
+ cow
+ apple,boy,cow
+ apple
+ cow
+ (blank line)
+
+ wouldn't it make more sense if the last line were:
+
+ apple,boy,cow
+
+ ?
+
+ I.e., letting you use the negative subscripts (meaning distance from
+ end of the string) inside a slice range might be rather nice.

The problem is that the scalar range operator .. only counts upwards,
and -1 is less than 0.

One way to do what you want would be to write:

  print join(@list[0 .. @list - 1]) . "\n";
 
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 17 Jul 2000 22:50:03 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Suggestion for syntax change
Message-Id: <3bRS8R$VC7@openbazaar.net>

Keith G. Murphy wrote ..
>In the following chunk of code:
>
>my @list = qw(apple boy cow);
>print $list[0] . "\n";
>print $list[2] . "\n";
>print join(',', @list[0..2]) . "\n";
>print $list[0] . "\n";
>print $list[-1] . "\n";
>print join(@list[0..-1]) . "\n";
>
>outputting:
>
>apple
>cow
>apple,boy,cow
>apple
>cow
>(blank line)
>
>wouldn't it make more sense if the last line were:
>
>apple,boy,cow
>
>?
>
>I.e., letting you use the negative subscripts (meaning distance from end
>of the string) inside a slice range might be rather nice.

while I disagree that 0..-1 should produce any output - I have often
wondered why the '..' operator doesn't work in both directions (at least
on 5.005_03 on Win32) .. the documentation is vague saying that

  "In list context, it returns an array of values counting (by ones)
   from the left value to the right value."

which doesn't discount counting from 10 to 1 .. but certainly 10..1
doesn't work .. all of the examples involve increasing values

btw .. my problem with 0..-1 is that it's some sort of special case for
negative numbers and how they relate to arrays .. IMHO $#array..0 should
work

--
  jason -- elephant@squirrelgroup.com --


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

Date: 17 Jul 2000 23:10:02 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Suggestion for syntax change
Message-Id: <3bRSXS$UiR@openbazaar.net>

jason wrote ..
>Keith G. Murphy wrote ..
>>In the following chunk of code:
>>
>>my @list = qw(apple boy cow);
>>print $list[0] . "\n";
>>print $list[2] . "\n";
>>print join(',', @list[0..2]) . "\n";
>>print $list[0] . "\n";
>>print $list[-1] . "\n";
>>print join(@list[0..-1]) . "\n";
>>
>>outputting:
>>
>>apple
>>cow
>>apple,boy,cow
>>apple
>>cow
>>(blank line)
>>
>>wouldn't it make more sense if the last line were:
>>
>>apple,boy,cow
>>
>>?
>>
>>I.e., letting you use the negative subscripts (meaning distance from end
>>of the string) inside a slice range might be rather nice.
>
>while I disagree that 0..-1 should produce any output

actually sorry - that's not clear .. I meant that the originator's code
where it used 0..-1 shouldn't produce any output (because the join is
joining $_ which is empty) .. the 0..-1 operator in my new '..' world
when used as I'm sure the originator meant to write ...

  print join','=>@list[0..-1];

should produce

  apple,cow

in case my other post hasn't surfaced yet .. the new '..' world is one
where '..' works for both incrementing and decrementing between it's
first and second argument .. so @list[0..-1] is the same as @list[0,-1]

--
  jason -- elephant@squirrelgroup.com --


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

Date: 17 Jul 2000 23:40:03 GMT
From: sumus@aut.dk.bbs@openbazaar.net (Jakob Schmidt)
Subject: Re: Suggestion for syntax change
Message-Id: <3bRTN3$UmO@openbazaar.net>

Bart Lateur <bart.lateur@skynet.be> writes:

> Jakob Schmidt wrote:
>
> >Your wish would require that the .. operator behaved in a different manner
> >when it finds itself used in array indexing than in other contexts. Isn't
> >that a bit... erm... ugly?
>
> You mean, like context sensitive? Gee, there's a novel idea. No, in Perl
> there's absolutely nothing that is context sensitive.

I deliberately didn't say that. I just asked if this specific example wouldn't
be ugly.

Well, wouldn't it?

--
Jakob


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

Date: 17 Jul 2000 23:20:03 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: Suggestion for syntax change
Message-Id: <3bRSk6$SiJ@openbazaar.net>

Jakob Schmidt wrote:

(about ".." inside @ary[0..-1])

>Your wish would require that the .. operator behaved in a different manner
>when it finds itself used in array indexing than in other contexts. Isn't
>that a bit... erm... ugly?

You mean, like context sensitive? Gee, there's a novel idea. No, in Perl
there's absolutely nothing that is context sensitive.

Doh...

--
	Bart.


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

Date: 17 Jul 2000 19:30:06 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: telephone answering machine
Message-Id: <3bRMka$VaJ@openbazaar.net>

Cheeby (sfox@earthlighttechnologies.com) wrote on MMDVIII September
MCMXCIII in <URL:news:8kknnf$q5i$1@jair.pressenter.com>:
@@ Has anyone out there tried to make a simple voice mail/answering machine in
@@ Perl?  I can't find a good program for my Linux box and thought I'd take a
@@ crack at it.  So I'm wide open to suggestions.


I'd use Coy.pm to generate the messages.



Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


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

Date: 17 Jul 2000 03:10:10 GMT
From: me@privacy.net.bbs@openbazaar.net (EM)
Subject: Testing and debuging scripts locally
Message-Id: <3bQjLa$W00@openbazaar.net>

Is there any way to test if a perl script works without having to go online
and upload it to my cgi-bin
Like it would be great if i could somehow start my browser and enter the
file as c:\scripts\script.cgi and be able to see it as if it were online

I am new to cgi so i dont know these things


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

Date: 17 Jul 2000 03:20:11 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Testing and debuging scripts locally
Message-Id: <3bQjYC$X9Y@openbazaar.net>

EM wrote ..
>Is there any way to test if a perl script works without having to go online
>and upload it to my cgi-bin
>Like it would be great if i could somehow start my browser and enter the
>file as c:\scripts\script.cgi and be able to see it as if it were online
>
>I am new to cgi so i dont know these things

a) install Perl .. I'm guessing from your headers that you're on Win32
 .. go to http://www.activestate.com/ActivePerl/ and download and install
ActivePerl

b) read the included documentation (from ActivePerl in your Start Menu)
- you can run the CGI programs on a number of web servers on the Win32
platform

--
  jason -- elephant@squirrelgroup.com --


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

Date: 17 Jul 2000 03:20:12 GMT
From: homer@simpsons.com.bbs@openbazaar.net (Homer)
Subject: Re: Testing and debuging scripts locally
Message-Id: <3bQjYD$XDb@openbazaar.net>

You can just run them in your browser as long as they don't have
environmental values. If they do, you'll probably need a scripting program
that allows you to simulate a browser and pre-set those environments.


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

Date: 17 Jul 2000 04:00:02 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Testing and debuging scripts locally
Message-Id: <3bQka2$S8I@openbazaar.net>

Homer wrote ..
>You can just run them in your browser as long as they don't have
>environmental values. If they do, you'll probably need a scripting program
>that allows you to simulate a browser and pre-set those environments.

oh great .. another troll is born

Ecco aka Homer - go away ..

this is a misleading answer .. a CGI script will not run as expected
straight from the browser - it will not output to the browser window and
on some systems it will not work at all

--
  jason -- elephant@squirrelgroup.com --


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

Date: 17 Jul 2000 10:00:02 GMT
From: ebohlman@netcom.com.bbs@openbazaar.net (Eric Bohlman)
Subject: Re: Testing and debuging scripts locally
Message-Id: <3bR861$U1Y@openbazaar.net>

jason (elephant@squirrelgroup.com) wrote:
: Ecco aka Homer - go away ..
:
: this is a misleading answer .. a CGI script will not run as expected
: straight from the browser - it will not output to the browser window and
: on some systems it will not work at all

In fact, the whole notion of "running a script in a browser" is an
incorrect mental model that causes many beginning CGI programmers to
waste a lot of time because they don't understand that *they* aren't
running the script, the Web server is, and the server doesn't have access
to the programmer's environment, current working directory, etc.


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

Date: 17 Jul 2000 12:30:02 GMT
From: john99@NOSPAMcanada.com.bbs@openbazaar.net (John)
Subject: Re: Testing and debuging scripts locally
Message-Id: <3bRC1Q$V82@openbazaar.net>

Hello

This is the best application that I've found
It has everything you need
http://www.indigostar.com/indigoperl.htm

EM wrote:
>
> Is there any way to test if a perl script works without having to go online
> and upload it to my cgi-bin
> Like it would be great if i could somehow start my browser and enter the
> file as c:\scripts\script.cgi and be able to see it as if it were online
>
> I am new to cgi so i dont know these things


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

Date: 18 Jul 2000 08:00:12 GMT
From: gellyfish@gellyfish.com.bbs@openbazaar.net (Jonathan Stowe)
Subject: Re: Testing and debuging scripts locally
Message-Id: <3bRgOG$V4L@openbazaar.net>

On Mon, 17 Jul 2000 01:01:32 +0100 EM wrote:
> Is there any way to test if a perl script works without having to go online
> and upload it to my cgi-bin
> Like it would be great if i could somehow start my browser and enter the
> file as c:\scripts\script.cgi and be able to see it as if it were online
>

I'm not sure what your problem is - with Perl installed you can run the
program at the command line on your machine.  If your problem is with
the CGI or some web server you should ask in the appropriate group in the
comp.infosystems.www. hierarchy.

/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 15 Jul 2000 02:00:02 GMT
From: callgirl@la.znet.com.bbs@openbazaar.net (Godzilla!)
Subject: Re: The newbie question
Message-Id: <3bPGU1$WPw@openbazaar.net>

Larry Rosler wrote:
 
> jason wrote:
> > Andrew Johnson wrote ..

(snippage)

> 2a) Don't consider any code 'tested' unless it compiles correctly
>     and executes without warnings when using the '-w' flag and
>     the 'use strict;' pragma.


If you were to run my creative and imaginative
scripts with pragma hints and strict, your system
would pop so many red flares it would attain critical
mass, blowup in your face rendering you into a grade B
sci-fi movie Toxic Avenger or perhaps a Swamp Thing.
Ironically, my private scripts are so sought after,
a very few have attempted internet crime to obtain
copies of my Perl creativity. Those few learned
hard lessons on how creative are my scripts, thanks
to not using pragma hints and strict.

Pragma hints and strict are both good tools for fresh
beginners, experienced beginners and good tools even
for those with intermediate skills in Perl. However, for
skilled Perl programmers, pragma hints, strict, are both
true nemesises being nothing more than well documented
glitches and bugs, deliberately written into Perl core.
Pragma hints and strict are Perl's equal to Microsoft's
classic Blue Screen of Death.

Don't miscontrue what I say here. I do support use of
pragma hints and strict under appropriate circumstances
and, as you pointed out, circumstances described in previous
articles for this thread, pragma hints would certainly
be beneficial and would have caught some problem coding.

What you can construe is I am saying making blanket
admonitions Perl programmers should always use pragma
hints, always use strict, is very poor advice, actually
advice which does guarantee script failure, at times. At
very best, pragma hints will mislead a progammer into
making script changes which worsen problems or curtail
creativity. Strict will simply crash a script to be ornery.
This is not so true for simple to moderately complex scripts,
types of scripts where pragma hints are beneficial. However,
for truly complex scripts or, in my case, creative scripts,
use of pragma hints, use of strict, is a well guaranteed
Blue Screen of Death.

Pragma hints and strict are good. Pragma hints and strict
are both useful tools. However, use the right tool for the
right job and, always remember to wear eye protection. Never
know when a pragma hint might fly into your eye leading you
to profusely swear like a salty sea seasoned sailor.

*lifts her pirate's style black eye patch*

Know what I mean?

Godzilla!


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

Date: 15 Jul 2000 10:50:01 GMT
From: godzilla@stomp.stomp.tokyo.bbs@openbazaar.net (Godzilla!)
Subject: Re: The newbie question
Message-Id: <3bPUKQ$W5n@openbazaar.net>

Bart Lateur wrote:

> Godzilla! wrote:
 
> >What you can construe is I am saying making blanket
> >admonitions Perl programmers should always use pragma
> >hints, always use strict, is very poor advice, actually
> >advice which does guarantee script failure, at times. At
> >very best, pragma hints will mislead a progammer into
> >making script changes which worsen problems or curtail
> >creativity.
 
> Examples?
 
> One example tat I can come up with is the "word frequency count"
> snippet:
>
>         while(<>) {
>             while(/(\w+)/) {
>                 $count{$1}++;
>             }
>         }
 
> It works without warnings, but that is only because its origin is in
> dark times, before common use of -w, so the implementors worked their
> way around any warnings which ordinarily ought to have appeared.
 
> It's true, if warnings were really pedantic, in cases like this, too,
> then this typical Perlish snippet would never have seen the light of
> day.


An earmark of a really good programmer is knowledge of when to
use selected tools and when not to use those tools. Another
earmark of good programming techniques is displayed by an
ability to bend or break rules in very positive productive
ways, most often to get a job done despite imposed constraints.

You boys like to play snippet golf which I do actually support
as it enhances techniques in Perl programming; it's creative
and does benefit all paying attention. However, being a rebel
at heart, snippet golf is not my game. My sport is to work at
bending and breaking rules of programming in as many ways as
possible, most often in very verbose ways. Suppose you could
say I play anti-snippet golf; just the reverse of what you
boys like to play. You have much better luck and better
scores however, than myself. Breaking rules is not easy.
It is a sport of searching for exploitable bugs and holes,
a sport of making Perl core think differently.

A problem arises with exploiting holes in Perl. Exploitation
is double edge sword and cuts twofold; beneficial and, quite
destructive if misused. For this reason, there are many topics
which should not be discussed publically, much to my annoyance.
Nonetheless, this is reality and there is a need to keep in
mind not all who participate in this group have good ethics.
Silence on some matters is prudent.

I have a long time, years long nemesis here. Pretty sure
this is becoming quite in evidence. This unpleasant yet
sometimes entertaining rivalry came about by invitation,
an invitation to 'crash test' a chat script, long ago.
No matter what this programmer did, I always found away
around his programming and crashed his beta chat. Towards
the end, when he felt most confident, I drew a small but
deadly dagger from my waistband, opting not to use brute
force of my sword. This dagger is a technique I developed
which actually reformats Perl core, in rather comical ways,
via a standard html form action. Unfortunately, my dagger
seems to have pierced his ego deeply as well. What I made
his beta chat do, although hilarious, he failed to take
notice of the humor. Suppose this might have to do with
a need to reset his entire server to clear what I did.

Goodness, the stories I could tell, such comedy. I do
zing him every so often, even now. Suppose I have earned
this chihuahua trouble nipping at my heels, daily.

May seem I am venturing away from your topic, Mr. Lateur,
which is true. Nevertheless, what I have exemplified and,
your thoughts have exemplified, venturing away from our
standardized techniques, programming in ways we are told
not to do, bending and breaking rules, is of benefit when
done so with good intent. It's a White Hat - Black Hat
Ying and Yang kinda thing. All depends if you are Flash
Gordon or Emperor Ming.

For this thread and in my case, by playing a different
game, anti-snippet golf, by bending and breaking rules,
I have learned how to write programs which experts would
glance over and pronounce fatally non-operative, least till
one of these experts visits with my androids and thinks,

"This friggin program actually works. Well I'll be."

In closing I will emphasize again an important point.
Staying within the rules, using standard methods, is
vitally important and should be practiced consistently.
It is equally important to not be pedantic, as you have
suggested. Pragmas and all that should be suggested very
often but not presented as absolute 'must do' rules. We
are also charged with being responsible in suggesting,

"Have you tried breaking some rules to solve your problem?"

Nice series of articles, Mr. Lateur and, yes, I agree
your code snippet related to the original topic of
this thread, is the best posted. Your solution is
a complex yet short one liner. My solution is about
as simple as the country girl I am truly. Each of
us have posted something unique, something different,
as  a result of thinking differently than the norm.

Godzilla!


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

Date: 17 Jul 2000 12:40:03 GMT
From: pjlees@ics.forthcomingevents.gr.bbs@openbazaar.net (Philip Lees)
Subject: Re: The problem of two Submit buttons
Message-Id: <3bRCE6$W4B@openbazaar.net>

On Fri, 14 Jul 2000 14:17:33 -0700, Larry Rosler <lr@hpl.hp.com>
wrote:

>In article <963583114.8285@itz.pp.sci.fi> on 14 Jul 2000 14:00:29 GMT,
>Ilmari Karonen <iltzu@sci.invalid> says...
>> In article <Pine.GHP.4.21.0007141529330.20198-100000@hpplus03.cern.ch>, Alan J. Flavell wrote:
>> >On Fri, 14 Jul 2000, Philip Lees wrote:
>> >
>> >> if ( ! $add_button eq "" ){
>> >> 	#add something
>> >
>> >Boggle.  Do you normally test for the negative of what you didn't
>> >want?
>>
>> Could've been worse.  He might have written it as:
>>
>>   unless ( ! $add_button ne "" ){
>
>Each of those is nonsense, because '!' binds with very high precedence
>to the succeeding operand.  So the logical negation of any string other
>than '0' is the null string.

Now this is interesting, at least to a beginner like me. I assumed
that:

if ( ! $a eq $b )

would compile to the same as:

if ( $a ne $b ).

If I understand you correctly, you're saying the the ! $a will be
evaluated before the comparison and so if $a="xyz" then ! $a will be
the null string and the comparison will always give the same result.

If this is true, then my crummy code shouldn't work at all - and yet
it does.

Out of interest, is

if ( !( $a eq $b ) )

equivalent to

if ( $a ne $b ) )?

Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: 17 Jul 2000 13:40:01 GMT
From: lr@hpl.hp.com.bbs@openbazaar.net (Larry Rosler)
Subject: Re: The problem of two Submit buttons
Message-Id: <3bRDf1$Tfg@openbazaar.net>

In article <3972f71c.18645050@news.grnet.gr>,
pjlees@ics.forthcomingevents.gr says...

 ...

> Out of interest, is
>
> if ( !( $a eq $b ) )
>
> equivalent to
>
> if ( $a ne $b ) )?

Yes.

--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 18 Jul 2000 10:48:12 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: This software is worth to try....
Message-Id: <MBWc5.325$Px6.32111@news.dircon.co.uk>

On Tuesday, 18 Jul 2000 16:28:32 -0600, sdf@sdf.com Wrote:
>
> Anyway, i think it is a very good software and it is worth to try.
> 

And I think you are a spammer and should go away.

/J\


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

Date: 16 Jul 2000 13:10:03 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: Time in mili-seconds
Message-Id: <3bQNRU$U4H@openbazaar.net>

On Sun, 16 Jul 2000 08:54:07 GMT, martho@my-deja.com <martho@my-deja.com> wrote:
>
>> You can, however, get _time_ in a finer resolution, but that is
>> in the Perl FAQ, so you have doubtless already seen that
>> solution.
>Which Perl-FAQ do you mean ? I found about 12...


   "How can I measure time under a second?"


>> Why won't the answer given there work for you?
>>
>>    perldoc -q time
>
>... I didn't get the perldoc in my perl-installation.


Then you did not get a successful installation.


>Where can I get
>the doc-files ?


They are included with the perl distribution.

Perl is free.

Download it, and you have the docs.


Or, click on "FAQs" at www.perl.com...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 17 Jul 2000 16:00:02 GMT
From: michael@visv.net.bbs@openbazaar.net (Michael Fischer)
Subject: To Schwartz or not to Schwartz?
Message-Id: <3bRHO4$UCH@openbazaar.net>

Some co-workers and I recently used the Schwartzian
transform to do some sorting of keys of hashes by
the values of a hashref embedded in the former hash.

Something like

my @sorted =
	map { $_->[0] }
	sort { $a-[1] cmp $b->[1] }
	map { [ $_, $$hash{'key1'}{'key2'}{'key3'} ] }
	( keys %hash );

However, another co-worker pointed out that this was
unnecessary, and that simply

my @sorted =
	sort { $$hash{$a}{'key2'}{'key3'} cmp $$hash{$b}{'key2'}{'key3'} }
	( keys %hash );

was both functional and more efficient.

We tried out the example from pp. 49-50 of _Effective
Perl_Programming_ in this way:

#!/usr/local/bin/perl -w

use strict;

my @files = <*>;

my @sorted_files = sort { -M $a <=> -M $b } @files;

foreach my $file (@sorted_files) {
        print "$file\n";
}

and found that it works.

So, we find ourselves wondering _when_ the Schwartz is
more appropriate or even necessary compared to this more
direct method. Is it that if the sorting keys and the
list to be sorted must be linked together because they
are originally not part of the same data structure?
( or fudgeable as 'the same data structure' as -M is
when applied to a list of filenames?)

Thank you for your time and input.

Michael Fischer
--
michael@visv.net


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

Date: 17 Jul 2000 20:10:05 GMT
From: lr@hpl.hp.com.bbs@openbazaar.net (Larry Rosler)
Subject: Re: To Schwartz or not to Schwartz?
Message-Id: <3bRO0T$VyH@openbazaar.net>

In article <39732E4D.63C784DC@visv.net> on Mon, 17 Jul 2000 16:03:30
GMT, Michael Fischer <michael@visv.net> says...
> Some co-workers and I recently used the Schwartzian
> transform to do some sorting of keys of hashes by
> the values of a hashref embedded in the former hash.
>
> Something like
>
> my @sorted =
> 	map { $_->[0] }
> 	sort { $a-[1] cmp $b->[1] }
> 	map { [ $_, $$hash{'key1'}{'key2'}{'key3'} ] }
> 	( keys %hash );

You mean the first key to be $_, not 'key1', as you show below.

> However, another co-worker pointed out that this was
> unnecessary, and that simply
>
> my @sorted =
> 	sort { $$hash{$a}{'key2'}{'key3'} cmp $$hash{$b}{'key2'}{'key3'} }
> 	( keys %hash );
>
> was both functional and more efficient.

How did you confirm that it was more efficient?

> my @sorted_files = sort { -M $a <=> -M $b } @files;

 ...

> and found that it works.

But you didn't find out how well it performs.  (The answer is that its
performance will be poor if there are many files in the array to be
sorted, because each file is stat-ted O(log N) times instead of once.)

> So, we find ourselves wondering _when_ the Schwartz is
> more appropriate or even necessary compared to this more
> direct method. Is it that if the sorting keys and the
> list to be sorted must be linked together because they
> are originally not part of the same data structure?
> ( or fudgeable as 'the same data structure' as -M is
> when applied to a list of filenames?)

The basic issue is whether the cost of computing and caching each key
once and retrieving it for comparison when needed is less than the cost
of computing each key every time it is needed.  This has no general
answer, but is true for all but the most trivial cases.  Your
multinested hash lookup may be one of those cases.  Only Benchmarking
can decide which is better.

For a much more complete discussion, see the following:

<URL:http://www.hpl.hp.com/personal/Larry_Rosler/sort/>

> Thank you for your time and input.

You're welcome.  The actual work was done a year ago.  :-)

--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

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 3732
**************************************


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