[18732] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 900 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 14 21:06:06 2001

Date: Mon, 14 May 2001 18:05:10 -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: <989888709-v10-i900@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 14 May 2001     Volume: 10 Number: 900

Today's topics:
    Re: [OT] Software Engineering at 14 (was: Re: Beginner' <nospam_dmmetler@bellsouth.net>
        ANNOUNCE: Switch 2.03 (Damian Conway)
    Re: Benefits of "strict" and "-w"? (Alan Barclay)
    Re: Benefits of "strict" and "-w"? <jfreeman@tassie.net.au>
    Re: Benefits of "strict" and "-w"? (Eric Bohlman)
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision (Craig Berry)
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision <eashton@chaos.wustl.edu>
    Re: dynamischer download - CGI <kreshover@web.de>
        foreach loop <b_many2k@yahoo.com>
    Re: foreach loop <jfreeman@tassie.net.au>
    Re: foreach loop (Eric Bohlman)
    Re: foreach loop <tony_curtis32@yahoo.com>
    Re: Http REFFERER -> IP ADDR (Alan Barclay)
    Re: if ($x in @a) equivalent in perl? <ren@tivoli.com>
    Re: if ($x in @a) equivalent in perl? <joe+usenet@sunstarsys.com>
    Re: perl book <uri@sysarch.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 14 May 2001 16:47:27 -0500
From: "Donna Metler" <nospam_dmmetler@bellsouth.net>
Subject: Re: [OT] Software Engineering at 14 (was: Re: Beginner's Language?)
Message-Id: <GIYL6.1152$M8.51688@news1.atl>

> Mrs Smith took her son Johnny to the music teacher.
>
> "My son Johnny is 14 and has been studying muic for 5 years. Do you think
he
> is old enough to write a piano concerto",  said Mrs Smith.
> "Well, that's a very young age to write such a complex work", said the
music
> teacher.
> "But Mozart wrote an opera at ago 10", said Mrs Smth.
> "Ah!! But he didn't have to ask", said the music teacher.
>
No, Mozart was TOLD!

Read a good western music history text (I suggest _A History of Western
Music_ by K. Marie Stolba or _The History of Western Music_ by Grout, and
you'll see that child prodigies are made, not born. While a pushy parent
will not a mozart make, neither would Mozart have been Mozart without
Leopold (his father, who pushed him both into public perfomance and
composition at an extremely early age-and did so to his daugher, as well).
Almost no child will make it through the first year of serious music study
without some significant parental pressure-it is not until the child really
starts to recognize their own improvement that the motivation becomes
internal. This is why  most good music teachers request at least a year's
committment from both the parents and the child-because in that first year
almost all children will want to quit, and if the parent lets them, probably
will never develop the level of ability needed for the practice to become
self-evident and the motivation to become internal.




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

Date: 14 May 2001 23:34:58 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Switch 2.03
Message-Id: <9dpq31$48s$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release

==============================================================================
                      Release of version 2.03 of Switch
==============================================================================


NAME
    Switch - A switch statement for Perl

DESCRIPTION

    Switch.pm provides the syntax and semantics for an explicit case
    mechanism for Perl. The syntax is minimal, introducing only the
    keywords C<switch> and C<case> and conforming to the general pattern
    of existing Perl control structures. The semantics are particularly
    rich, allowing any one (or more) of nearly 30 forms of matching to
    be used when comparing a switch value with its various cases.

AUTHOR
    Damian Conway (damian@conway.org)

COPYRIGHT
    Copyright (c) 1997-2000, Damian Conway. All Rights Reserved. This module
    is free software. It may be used, redistributed and/or modified under
    the terms of the Perl Artistic License (see
    http://www.perl.com/perl/misc/Artistic.html)


==============================================================================

CHANGES IN VERSION 2.03


	- Fixed bug in 'fallthrough' specifications (thanks Robin)

	- Silenced gratuitous warnings for undefined values as
	  switch or case values


==============================================================================

AVAILABILITY

Switch has been uploaded to the CPAN
and is also available from:

	http://www.csse.monash.edu.au/~damian/CPAN/Switch.tar.gz

==============================================================================


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

Date: 14 May 2001 21:55:28 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Benefits of "strict" and "-w"?
Message-Id: <989877250.893709@elaine.furryape.com>

In article <xris-689393.16002514052001@news.evergo.net>,
xris  <xris@dont.send.spam> wrote:
> I'm wondering what the advantages are. 

-w gives information on things you've done, which you probably didn't
mean to do. For example, variables used only once, variables used
as if they contain a value when they don't, very recursive subroutines
etc. See perldoc perlrun for the full list.

use strict tries to enforce good programming style, by ensuring that
variables & subroutines are declared before use, and references aren't
soft. If you typo on a variable name here, then the program will fail
to compile. see perldoc strict for all the details.

If you use both on all non-trivial programs, you'll get better programs
with less bugs.


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

Date: Tue, 15 May 2001 09:56:53 +1000
From: James freeman <jfreeman@tassie.net.au>
Subject: Re: Benefits of "strict" and "-w"?
Message-Id: <3B0070C5.BEDD8336@tassie.net.au>

xris wrote:

> I know this is probably in the faq somewhere, but I don't know where to
> start looking, so I'm asking here (my teachers always told me to ask
> questions, no matter how stupid they sounded).
>
> I've been messing with perl for years, but as I've had no formal
> training, and Larry Wall's perl book doesn't stress either of these
> options (let alone give me enough info to even know what they REALLY
> do), I never bothered using them.  Since I've decided that my coding
> abilities have finally matured enough that I really should start using
> these, I'm wondering what the advantages are.  Is compilation/execution
> faster?  More reliable?

In short less occult bugs in code that you will have debugged faster in the
first place, with way less stress.

> Thanks,
>
> Chris

You have been given a couple of first class answers, plus pointers to more info.

On the practical side it takes a bit of time to get familiar with writing
programs that run under strict and -w. I suggest also adding a 'use
diagnostics;'  line at the top of your program to expand the descriptive text
you get from the short to verbose form until you work out what you are being
told. You won't need it after a few days/weeks.

#!/usr/bin/perl -w
use strict;
use diagnostics;

Once you start getting used to declaring your variables, mostly with my,
initializing your variables (even if you want them to be equal to null), and a
few other small things the rewards are that Perl picks up heaps of subtle and
not so subtle errors for you and then tells you exactly what and where they are.
*It is worth the initial annoyance*, and initially you will probably find it a
bit annoying. You may find Mark Jason Dominus's "Coping with Scoping" helpful as
you slide into use strict.

http://perl.plover.com/FAQs/Namespaces.html

You can always un-strict or un-warn a block of code if you really want to
thusly:

#!/usr/bin/perl -w
use strict;

# warnings and strict are in force here

{
    no strict;
    no warnings;
    # no strict and warnings in this block so do naughty things
}

# warnings and strict back in force here, so back on good behavior you naughty
little coder you


Cheers

James

PS I know my sig is way too long but I just finished it and....

--
################################################################
#                                                              #
#        A Thought on Perl Poetry and the Immortal JAPH        #
#                                                              #
#  I, require strict* and do not require warnings*. My answer  #
#  equals reference you unless answer equals 42. Question: If  #
#  defined, by this paradigm, do you do, the hacker foo?  Now  #
#  join the data (why Fs & Os?), so the space or newline goes  #
#  Character evaluate: Reverse split null, then for each foo:  #
#  You ate foo, but I ate two. Answer -> Join with null, sort  #
#  the spots, and print it join the dots. Go now and exit, do  #
#  not die, else go to question and answer why? JAPH! (c)JADF  #
#                                                              #
################################################################

I, require strict and do(not require warnings); my $answer = \$u
unless $answer == '42'; Question: if(defined by this_paradigm do
you_do_the_hacker_foo(??)){sub AUTOLOAD{$_=$now=join'the',<DATA>
;y?FO?01?; s.o|the| |\n..goe;s/(.{7})/(chr(eval'($u,$ate)=(0,1);
foreach $foo(reverse split "",$1){$u+=$ate*$foo;$but_I=$ate*=2;}
$$answer'))/eg;$_= join'',sort/(..)/g and print join'',/.(.)/go;
$now and exit, do(not die)}}else{goto Question and $answer;y???}
 __DATA__

OOFFOOOOOFOO      OFOO       OOFFFOOOFFO    FOOO    FFOO    OFFO
FFFOOFOOOFOF    OFFFFOOF     OFFFOOFOOOOO   OFOO    FOFO    FFFF
    FOOO      FOOF    OOFO   FOOO    OFOF   OOOO    FFOF    OOOF
    OFOF      OOFO    FFFO   OFFF    OOOO   OFFO    OOOF    FFFO
    OFFO      FOFOOOFFOFFO   FFFFFOOOFOFF   OOFFFFOOOFFO    FFOO
    OFOF      FOOFFOFOFOFF   FFFOOFFOOFO    FFFFFOOOOFOF    OOOF
    FFOO      OOOF    FFOO   OFOO           FFOO    OFFF    FOOO
FF  OFOO      FOOO    OOOF   FOFO           OOFO    OFFO
OOFFOFOO      FFFO    FOOO   FOFO           OOFO    FFOO    OOFO
 FFOOOF       OOOO    OFFO   FOOO           OOFF    OFOF    FFFO




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

Date: 15 May 2001 00:37:33 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Benefits of "strict" and "-w"?
Message-Id: <9dptod$q4r$1@bob.news.rcn.net>

Craig Berry <cberry@cinenet.net> wrote:
> And that's why most of us recommend that warnings and strict be enabled
> for any script, and certainly any script (or code fragment) you want the
> readers of clpm to help you debug.  By elminating the most common silent
> DWIM errors of 'raw' perl, this practice will quite often solve your
> problems before you need to ask us for help. 

An important point is that due, among other things, to a phenomenon called 
"psychological set," it is *much* easier for a computer to detect certain 
types of errors, particularly the types caught by -w and use strict, than 
it is for a human.  Thus, using -w and strict reduces the need for humans 
to do what should be machine work.  In particular, asking questions here 
about problems with code that hasn't been tested under -w and strict is 
regarded as offensive by a lot of people because it amounts to asking 
them to do machine work (you wouldn't post a list of 1000 numbers and ask 
someone to add them up, would you?).

Psychological set is the built-in human tendency to perceive what "should" 
be there rather than what actually is there (the late Douglas Adams' SEP 
Field worked by taking advantage of psychological set).  It becomes a real 
problem when you're debugging code or proofreading manuscripts, because 
most of the time you'll see what you intended to write rather than what 
you actually *did* write.  Computers, OTOH, have no notion of how things 
"should" be; they can only deal with what's actually there, so they can 
easily catch those sorts of errors.



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

Date: Mon, 14 May 2001 22:09:49 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <tg0ltd6m9nqgd6@corp.supernews.com>

Chris Stith (mischief@velma.motion.net) wrote:
: Oh, i must have? You presume too much. Kira was violating
: an RFC by posting from an assumed but valid domain. Randal
: told her that was a bad idea. When she didn't listen, he
: proved it was a abad idea by example.

Pardon me for pointing this out, but Randal of all people should
understand the pitfalls of proof by example in cases like this.  Randal's
actions came across to many readers as vindictive and unnecessary.
Annoying posters are the precise reason why the net gods gave us
killfiles.  There's little need to punish them beyond the simple response
of ignoring them with technological assistance.

: Examples are an effective
: way to teach, communicate, and learn. I think Kira learned
: something from that. I don't call that "morally repugnant".
: I might call it a harsh decision on Randal's part, but I
: don't think it to be immoral or unethical.

I wouldn't go as far as either of those, but I would characterize it as
"ill advised" and "counter to his interests in making a larger point."

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Tue, 15 May 2001 00:31:07 GMT
From: Elaine Ashton <eashton@chaos.wustl.edu>
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <B725F133.EBC%eashton@chaos.wustl.edu>

On 5/14/01 5:21 PM, in article tg0j2pn2ph55a0@corp.supernews.com, "Chris
Stith" <mischief@velma.motion.net> wrote:
> Oh, i must have? You presume too much. Kira was violating
> an RFC by posting from an assumed but valid domain. Randal
> told her that was a bad idea. When she didn't listen, he

No, he registered the domain as it was an available domain
and then threatened to retroactively remove all postings
from that domain. 

> proved it was a abad idea by example. Examples are an effective
> way to teach, communicate, and learn. I think Kira learned
> something from that. I don't call that "morally repugnant".
> I might call it a harsh decision on Randal's part, but I
> don't think it to be immoral or unethical.

Good examples are effective. People being assholes are not.
I would call it unethical and, fortunately, there are those
in the USENET cabal who thought so as well.

> Ohhhhhhhh. Naaaaaame Caaaaalllling... That hurts almost
> enough for me to notice. I've been called a lawyer that
> never loses. *weep*

Well...or play one on TV. He actually did lose once. Also,
I didn't dub you PM, but it seemed to stick :)
 
> The more people shove _me_ away, the more _I_ want to be
> near? Again, you presume to know more about me than you do.

This was the 3rd person hypothetical voice. Generally
scarcity and status tend to make things more desirable.

> I'm not trying to get Kira to leave. You presume too much.
> I don't really care to change her mind, either. I only
> think it's right that I say something in this public forum
> about her posts which might change someone else's mind.
> It's called discussion. That's _why_we're_here_.

You suggested she leave in a 'why don't you just go away'
fashion. She isn't and I find it interesting that the same
thing seems to continue.

e.



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

Date: Tue, 15 May 2001 02:15:03 +0200
From: "Steffen Retzlaff" <kreshover@web.de>
Subject: Re: dynamischer download - CGI
Message-Id: <9dps41$o4p$1@newsread2.nexgo.de>

Ulrich Nehls schrieb:
> "Thorsten Stueben" <thorsten@stueben.de> wrote in message
> news:9dg1t4$eao$1@donald.stueben.inka.de...
> > ich habe folgendes vor: Ich möchte gerne Freunden, bestimmte Bilder die
> ich
> > auf meiner Homepage habe zum downloaden via FTP anbieten.
> > Ist das möglich? Und wenn ja, wie schaffe ich es die Files per zip zu
> > komprimieren und anschließend zurückzugeben?
>
> Die gängigen Grafikformate (jpg, gif) sind ihrer Natur nach bereits
> komprimiert, so daß du nach dem zippen allenfalls eine Rate von <1%
> feststellen wirst. Das Ganze ist von daher eigentlich nicht wert, daß man
> dafür ein perlscript schreibt ...

Es geht wahrscheinlich gar nicht um das komprimieren sondern um das
Zusammenfassen in einer Datei, damit die Benutzer nicht so häufig die
'Speichern unter...'-Dialoge haben.

Zum 'Komprimieren' gibt es sicher ein ZIP-Modul bzw. zum Zusammenfassen ein
TAR-Modul bei CPAN.

Steffen Retzlaff




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

Date: Mon, 14 May 2001 23:42:31 GMT
From: "Brent Reynolds" <b_many2k@yahoo.com>
Subject: foreach loop
Message-Id: <H3_L6.44928$q51.409022@news1.gvcl1.bc.home.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0018_01C0DC94.F4EE43A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

how would I make a loop that repeats a certin numer of times?

eg:

foreach (would I put some thing here?)
{
print "$number";
$number =3D $number + 1;
}

how would I loop that say 30 times?

------=_NextPart_000_0018_01C0DC94.F4EE43A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>how would I make a loop =
that&nbsp;repeats a certin=20
numer of times?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>eg:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>foreach (would I put some thing =
here?)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>print "$number";</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>$number =3D $number + 1;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>how would I loop that say 30=20
times?</FONT></DIV></BODY></HTML>

------=_NextPart_000_0018_01C0DC94.F4EE43A0--



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

Date: Tue, 15 May 2001 10:33:10 +1000
From: James freeman <jfreeman@tassie.net.au>
Subject: Re: foreach loop
Message-Id: <3B007946.2AE1109B@tassie.net.au>

Brent Reynolds wrote:

> how would I make a loop that repeats a certin numer of times? eg: foreach
> (would I put some thing here?){print "$number";$number = $number + 1;} how
> would I loop that say 30 times?

First netiquette.

You have posted using MIME (you probably selected a send message as HTML
option). Anyway when you post to newsgroups be aware that many people who read
them can only read plain text, so if you want to reach the entire audience post
in plain text only. Not posting in plain text and adding attachments are sins
comparable with squeezing the toothpaste from the middle of the tube which I
believe remains a hanging offense in some jurestictions. If you don't you will
just get more answers starting like this and ignoring your question which by the
way I do answer at the end.

As a result of posting here you will have recieved a welcome document - please
read it. It has a wealth of useful info in it.

This is an extremely basic question. People on this news group are generally
quite happy to help you provided you take a little time to help yourself first.
Reference to virtually any text book on perl, the extensive Perl FAQs, most of
the basic online Perl tutorials...... would have provided the answer to this
question. Please take the time to look as *some* of the members of the group
take being asked very basic questions as a personal insult.

A good link to start your journey into this wonderful language is:

http://www.perl.com/pub/v/faqs

Here you will find links to a wealth of information. For the record, and to show
I am not a completely mean bastard, here are just three of the ways you can do
it :-)

for(my $i = 1; $i <= 40; $i++) {
    print "$i ";
    $array[$i] = $i;
}

print "\n";

my $count = 0;
while ($count <30) {
   $count++;
   print "$count ";
}

print "\n";

$count = 0;
for (@array) {
   print "$_ ";
   last if $count >= 30;
   $count++;
}

Cheers

James

--
################################################################
#                                                              #
#        A Thought on Perl Poetry and the Immortal JAPH        #
#                                                              #
#  I, require strict* and do not require warnings*. My answer  #
#  equals reference you unless answer equals 42. Question: If  #
#  defined, by this paradigm, do you do, the hacker foo?  Now  #
#  join the data (why Fs & Os?), so the space or newline goes  #
#  Character evaluate: Reverse split null, then for each foo:  #
#  You ate foo, but I ate two. Answer -> Join with null, sort  #
#  the spots, and print it join the dots. Go now and exit, do  #
#  not die, else go to question and answer why? JAPH! (c)JADF  #
#                                                              #
################################################################

I, require strict and do(not require warnings); my $answer = \$u
unless $answer == '42'; Question: if(defined by this_paradigm do
you_do_the_hacker_foo(??)){sub AUTOLOAD{$_=$now=join'the',<DATA>
;y?FO?01?; s.o|the| |\n..goe;s/(.{7})/(chr(eval'($u,$ate)=(0,1);
foreach $foo(reverse split "",$1){$u+=$ate*$foo;$but_I=$ate*=2;}
$$answer'))/eg;$_= join'',sort/(..)/g and print join'',/.(.)/go;
$now and exit, do(not die)}}else{goto Question and $answer;y???}
 __DATA__

OOFFOOOOOFOO      OFOO       OOFFFOOOFFO    FOOO    FFOO    OFFO
FFFOOFOOOFOF    OFFFFOOF     OFFFOOFOOOOO   OFOO    FOFO    FFFF
    FOOO      FOOF    OOFO   FOOO    OFOF   OOOO    FFOF    OOOF
    OFOF      OOFO    FFFO   OFFF    OOOO   OFFO    OOOF    FFFO
    OFFO      FOFOOOFFOFFO   FFFFFOOOFOFF   OOFFFFOOOFFO    FFOO
    OFOF      FOOFFOFOFOFF   FFFOOFFOOFO    FFFFFOOOOFOF    OOOF
    FFOO      OOOF    FFOO   OFOO           FFOO    OFFF    FOOO
FF  OFOO      FOOO    OOOF   FOFO           OOFO    OFFO
OOFFOFOO      FFFO    FOOO   FOFO           OOFO    FFOO    OOFO
 FFOOOF       OOOO    OFFO   FOOO           OOFF    OFOF    FFFO




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

Date: 15 May 2001 00:40:25 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: foreach loop
Message-Id: <9dpttp$q4r$2@bob.news.rcn.net>

Brent Reynolds <b_many2k@yahoo.com> wrote:
> how would I make a loop that repeats a certin numer of times?

> eg:

> foreach (would I put some thing here?)
> {
> print "$number";
> $number = $number + 1;
> }

> how would I loop that say 30 times?

Take a look at the perlsyn document that came with your perl installation, 
particularly the part about for/foreach loops.  You'll know at least two 
ways to do it after reading it.



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

Date: 14 May 2001 19:47:21 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: foreach loop
Message-Id: <871yprbfqe.fsf@limey.hpcc.uh.edu>

>> On Mon, 14 May 2001 23:42:31 GMT,
>> "Brent Reynolds" <b_many2k@yahoo.com> said:

> how would I make a loop that repeats a certin numer of
> times?
> foreach (would I put some thing here?)
> {
>   print "$number";
>   $number = $number + 1;
> }
> how would I loop that say 30 times?

You can simplify your outline significantly:

  print "$_\n" for 1..30;

(The newline makes it more readable.)

Or if you need a more interesting loop statement:

  foreach my $n (1..30) {
    do_something_with($n);
  }

"perldoc perlop" to find out more about ".." (Range Operators).

hth
t
-- 
Just reach into these holes.  I use a carrot.


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

Date: 14 May 2001 21:38:54 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Http REFFERER -> IP ADDR
Message-Id: <989876262.401940@elaine.furryape.com>

In article <87k83kiw34.fsf@limey.hpcc.uh.edu>,
Tony Curtis  <tony_curtis32@yahoo.com> wrote:
>>> On 14 May 2001 00:05:40 GMT,
>>> gorilla@elaine.furryape.com (Alan Barclay) said:
>
>> In article <9dn2o5$1rh$1@plutonium.btinternet.com>,
>> Ian Knight <i.m.knight@btinternet.com> wrote:
>>> How would i get the IP of the ENV variable
>>> HTTP_REFERER.
>>> 
>>> The HTTP_REFERER return eg www.somedomain.com i want
>>> 123.456.789.010 or whatever
>          (789 ????? :-)
>
>> You want gethostbyaddr(); Check perlfunc for the
>                    ^^^^
>                    name() assuming it *is* a name.

Yes, of course. Brain gear wrong in.

>> the user follows the link from a private intranet, then
>> the name could only be resolvable by systems on that
>> private intranet.
>
>Wouldn't you get the proxy/NAT address in that case?

The proxy address would be in REMOTE_ADDR. The HTTP_REFERER contains
the URL of the previous page, and isn't translated. 



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

Date: 14 May 2001 16:12:44 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <m3zocfk52r.fsf@dhcp9-172.support.tivoli.com>

On 13 May 2001, joe+usenet@sunstarsys.com wrote:

>   % cat try.pl
>   #!/usr/bin/perl
>   use Benchmark;
>   @a = "a" .. "z";
> 
>   timethese -5, {
>         for  => q/ $m = 0; for (@a){ $_ eq $ARGV[0] and $m=1 and
>         for  => last }/,
>         grep => q/ $m = grep {$_ eq $ARGV[0]} @a/,
>         hash => q/ my %h; undef @h{@a}; $m = exists $h{$ARGV[0]}/,
>   };
> 
>   % ./try.pl a
>    for:  46097.80/s (n=230950)
>   grep:   1855.29/s (n=9295)
>   hash:   7554.69/s (n=37849)
> 
>   % ./try.pl i
>    for:   7419.16/s (n=37170)
>   grep:   1833.67/s (n=9205)
>   hash:   7509.70/s (n=37924)
> 
>   % ./try.pl z
>    for:  2652.80/s (n=13264)
>   grep:  1836.33/s (n=9200)
>   hash:  7531.60/s (n=37658)

What version of Perl was this?  With:

This is perl, v5.6.0 built for i386-linux

I get notably different relative results:

% ./try.pl a
 for: 235410.82/s (n=1240615)
grep:  35269.60/s (n=184460)
hash:  19055.68/s (n=100614)

% ./try.pl i
 for:  64480.89/s (n=334011)
grep:  35202.29/s (n=184460)
hash:  19329.13/s (n=99545)

% ./try.pl z
 for:  25214.39/s (n=133132)
grep:  34871.46/s (n=184470)
hash:  19086.85/s (n=98679)

 ...not that it really matters.

Also, this benchmark includes the hash initialization in the timing,
which is, I believe, intentional.  But if the hash can be used to
begin with, the benefit is huge:

% ./try.pl a
preloaded_hash: 857706.55/s (n=4322841)

% ./try.pl i
preloaded_hash: 865723.36/s (n=4631620)

% ./try.pl z
preloaded_hash: 856341.01/s (n=4427283)

-- 
Ren Maddox
ren@tivoli.com


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

Date: 14 May 2001 20:27:36 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <m31ypr318n.fsf@mumonkan.sunstarsys.com>

Ren Maddox <ren@tivoli.com> writes:

> On 13 May 2001, joe+usenet@sunstarsys.com wrote:
> >   % ./try.pl a
> >    for:  46097.80/s (n=230950)
> >   grep:   1855.29/s (n=9295)
> >   hash:   7554.69/s (n=37849)
> > 
> >   % ./try.pl i
> >    for:   7419.16/s (n=37170)
> >   grep:   1833.67/s (n=9205)
> >   hash:   7509.70/s (n=37924)
> > 
> >   % ./try.pl z
> >    for:  2652.80/s (n=13264)
> >   grep:  1836.33/s (n=9200)
> >   hash:  7531.60/s (n=37658)
> 
> What version of Perl was this?  With:

Damn good question. They were run yesterday
with 5.005_03 on Linux 2.4.3, but I can't reproduce 
them today :-\

As they are rediculously slow compared to today's
figgers, I can only guess that some resource was
exhausted somewhere.  They now appear to be worthless
results, as a recheck now shows my results agree
completely with yours (your speeds are double mine
running 5.00503 on a 225MHz Linux box).

> This is perl, v5.6.0 built for i386-linux
> 
> I get notably different relative results:
> 
> % ./try.pl a
>  for: 235410.82/s (n=1240615)
> grep:  35269.60/s (n=184460)
> hash:  19055.68/s (n=100614)
> 
> % ./try.pl i
>  for:  64480.89/s (n=334011)
> grep:  35202.29/s (n=184460)
> hash:  19329.13/s (n=99545)
> 
> % ./try.pl z
>  for:  25214.39/s (n=133132)
> grep:  34871.46/s (n=184470)
> hash:  19086.85/s (n=98679)
> 
> ...not that it really matters.
> 
> Also, this benchmark includes the hash initialization in the timing,
> which is, I believe, intentional.  But if the hash can be used to
> begin with, the benefit is huge:
> 
> % ./try.pl a
> preloaded_hash: 857706.55/s (n=4322841)
> 
> % ./try.pl i
> preloaded_hash: 865723.36/s (n=4631620)
> 
> % ./try.pl z
> preloaded_hash: 856341.01/s (n=4427283)

That makes perfect sense.

-- 
Quintessential Williams: facilitate dot-com functionalities 


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

Date: Mon, 14 May 2001 23:13:24 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl book
Message-Id: <x7d79ba5hj.fsf@home.sysarch.com>

>>>>> "CD" == Cameron Dorey <camerond@mail.uca.edu> writes:

  CD> Actually, I recently wrote to Tom to ask if he might be able to
  CD> update his Critiques page, but apparently (and, if so,
  CD> understandably), he isn't able to do it right now. There are
  CD> several good books out there which are not mentioned because they
  CD> are too recent for the review page.  Is Uri's (sorry, uri's) page
  CD> still up, and/or are there others out there that we should be
  CD> pointing to for coverage of the recent literature?

my books page is still active but out of date and needs work. i am
looking for someone to take over the lead on it. it needs many more book
entries most of which can be automated (i have the basic code for
that). also it needs reviews and ratings. if someone want to work on it
i will give them the code and any help they need. this would be a good
side project for someone who wants to learn more about perl data
structures, basic object code, cgi, LWP::Parallel etc.

take a look at the page at: 

	http://www.sysarch.com/cgi-bin/perl_books

and the code can be found at 

	http://www.sysarch.com/perl/perl_books.pl

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

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.  

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 V10 Issue 900
**************************************


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