[10149] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3742 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 17 15:07:42 1998

Date: Thu, 17 Sep 98 12:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Sep 1998     Volume: 8 Number: 3742

Today's topics:
    Re: Calling another script from perl <J.D.Gilbey@qmw.ac.uk>
        Can not autoload variables using the Perl Compiler (5.0 ffdixon@my-dejanews.com
    Re: concatinate variables (Abigail)
    Re: Cookies? wyndo@cxo.com
    Re: Cookies? wyndo@cxo.com
    Re: CPAN.pm shell from behind a firewall <eashton@bbnplanet.com>
    Re: Extract email address from user profile? <racronkite@hrl.com>
    Re: Formatting a variable to three digits <jeff@vpservices.com>
    Re: how safe is xor encryption ? (Mark-Jason Dominus)
    Re: how safe is xor encryption ? (Mark-Jason Dominus)
    Re: how safe is xor encryption ? <fsg@newsguy.com>
        How to "execute" a CGI (Perl) script inside a HTML page <jian@cisco.com>
        Installing/Making on win95 <jeff@vpservices.com>
    Re: internal error 500 (Abigail)
    Re: mod function in PERL? <barnett@houston.Geco-Prakla.slb.com>
    Re: mod function in PERL? <eashton@bbnplanet.com>
    Re: mod function in PERL? (Andre L.)
    Re: more regex/pattern substitution (Abigail)
        OT: Re: stock quote service <featheredfrog@geocities.com>
    Re: Perl & Java - differences and uses bjohnsto_usa_net@my-dejanews.com
    Re: Removing double entries from array <barnett@houston.Geco-Prakla.slb.com>
    Re: Removing double entries from array (Marc-A. Woog)
    Re: Removing double entries from array (David A. Black)
    Re: SSI , Perl and IIS <alves@business-village.com>
    Re: stock quote service <p-fein@uchicago.edu>
        Where is TIX? <lesaber@hotmail.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 17 Sep 1998 19:41:08 +0100
From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk>
Subject: Re: Calling another script from perl
Message-Id: <360157C4.1D7EFEFD@qmw.ac.uk>

Matt Turner wrote:
> 
> Say that I wanted to call another shell script or perl script from
> perl.  How can I do this?  I think it has something to do with the
> "system command".  For example, say I wanted to call a script called
> runme with a -d parameter from perl.  Would this be how to do it:
> 
> system ("runme -d")
> 
> Also, does the perl script continue running once the srcipt "runme" is
> done running.  In other words,  does the script continue running, wait
> for the called script to finish, or terminate once the called script is
> called?

See the system and exec entries in perlfunc.

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

            Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
       Dept of Mathematical Sciences, Queen Mary & Westfield College,
                  Mile End Road, London E1 4NS, ENGLAND
      -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-


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

Date: Thu, 17 Sep 1998 17:57:46 GMT
From: ffdixon@my-dejanews.com
Subject: Can not autoload variables using the Perl Compiler (5.005_52)
Message-Id: <6triip$do0$1@nnrp1.dejanews.com>

I'm tring out the Perl Compiler with 5.005_52; However, when I compile a perl
program that uses an external module, the compiler can't find the module's
variables.

Here's a simple example:

% more foo.pl
#!/usr/bin/perl

use Fcntl ':flock';

print "Lock: $LOCK_EX\n";

% perl -MO=C,-ofoo.c foo.pl
foo.pl syntax OK
No definition for sub Fcntl::LOCK_EX
No definition for sub Fcntl::LOCK_EX (unable to autoload)
No definition for sub Fcntl::LOCK_UN
No definition for sub Fcntl::LOCK_UN (unable to autoload)
No definition for sub Fcntl::LOCK_NB
No definition for sub Fcntl::LOCK_NB (unable to autoload)
No definition for sub Fcntl::LOCK_SH
No definition for sub Fcntl::LOCK_SH (unable to autoload)


How do I help the compiler to find (autoload) the definition for variables
such as LOCK_EX?

Any help would be much appreciated.

Regards,... Fred

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 17 Sep 1998 18:20:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: concatinate variables
Message-Id: <6trjsm$kbu$1@client3.news.psi.net>

Tien Pham (tpham@ee.gatech.edu) wrote on MDCCCXLIII September MCMXCIII in
<URL: news:36011A60.23EDE5D0@ee.gatech.edu>:
++ Hi there:
++ 
++ How do we concatinate variables in the LHS of the "=" in Perl 5?
++ I mean
++ 
++ ---------------
++ #!/usr/local/bin/perl
++ 
++ @x = (1,0,1);
++ 
++ for $num (0..2) {
++   $tmp_$num[$num] = $x[$num];
++   print STDOUT "$num\t$tmp_$num[$num]\tqqq\n";
++ }
++ -------------
++ 
++ so that I can create vars tmp_0, tmp_1, and tmp_2.

That's why we have arrays....

What's wrong with:

    foreach my $num (0 .. 2) {
        $tmp [$num] [$num] = $x [$num];
        print "$num\t$tmp[$num][$num]\tqqq\n";
    }



Of course, if you really insist:

    foreach my $num (0 .. 2) {
        ${"tmp_$num"} [$num] = $x [$num];
        print "$num\t$tmp[$num][$num]\tqqq\n";
    }



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: Thu, 17 Sep 1998 18:21:00 GMT
From: wyndo@cxo.com
Subject: Re: Cookies?
Message-Id: <6trjuc$f3s$1@nnrp1.dejanews.com>


> How do you set a cookie in Perl(Win32)? I tried to set an environment
> variable but the next .pl file could not get the value from the variable. Is
> there any way to pass a variable without a post or get with the value in the
> url?

Call your CGI program like this:

whatever.cgi?somevar=15&someothervar=18&whatever=6

This will AUTOMATICALLY be viewed by perl as a "GET" operation. Just read all
those variables in like normal. You should be able to completely maintain
state among multiple CGI programs by simply generating all your links via CGI
with the right parameters after the URL. I'm writing a full sized RPG (web
game) in Perl, and I'm maintaining state this way, only using a cookie as a
"checksum" to make sure nobody cheats.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 17 Sep 1998 18:23:12 GMT
From: wyndo@cxo.com
Subject: Re: Cookies?
Message-Id: <6trk2f$f67$1@nnrp1.dejanews.com>


> How do you set a cookie in Perl(Win32)? I tried to set an environment
> variable but the next .pl file could not get the value from the variable. Is
> there any way to pass a variable without a post or get with the value in the
> url?

I re-read your message. You're wanting to do this WITHOUT putting the extra
data on the URL ("get") and without using a form or hidden form ("post")
right?

Wow. Okay well you can use cookies. Just do a dejanews search on the subject
and something is bound to pop up with the answer. the problem with
environment variables is you're in a stateless environment. When your CGI
ends, so does any environs it sets.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 17 Sep 1998 18:02:16 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: CPAN.pm shell from behind a firewall
Message-Id: <36014C44.565288C1@bbnplanet.com>

jboes@qtm.net wrote:

> Does anyone have experience to share about how to configure CPAN.pm so that
> the shell can be used from behind a firewall? I've tried several variants on
> feeding it the name of my proxy server, but whenever I try to actually use
> it, it times out trying to use /usr/bin/ftp.

You'll need to talk to your network admin and find out what ports are
allowed with the firewall. Typically passive FTP will work through a
firewall but it may be that it is configured not to allow traffic on
high numbered ports as well.

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: Thu, 17 Sep 1998 08:44:59 -0700
From: "Robert Cronkite" <racronkite@hrl.com>
Subject: Re: Extract email address from user profile?
Message-Id: <6traps$gna@hacgate2.hac.com>

Thank God there's not!






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

Date: 17 Sep 1998 17:33:45 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Formatting a variable to three digits
Message-Id: <36014755.F450FA75@vpservices.com>

Your problem sounds like it has to do with numeric precision and that's
probably where you should check.  OTOH, maybe you are asking something
more general about the differences between numbers and strings.  If so
maybe the "James Bond Problem" will be of interest.

I often want to name things using strings that include numbers of
specified length (e.g. my007.html, my008.html).  Then I want to go
forward and backwards between them.  Forwards is fine - autoincrement is
magical and increments "007" to "008".  But autodecrement is not magical
so "008" is decremented to "7".  Poor Bond, he's lost his double-oh.  To
kludge this, I have my own decrement function (shown below).  

If anyone knows a simpler/cleaner way to do this, please let me know.

------ start snippet ----------
#!/usr/local/bin/perl -w
print decr('008');   # outputs: 007

sub decr {
  ###################################################################
  # autodecrements a number, then puts leading zeroes in front
  # e.g.: decr('008')='007' ...  decr('08')='07'
  # by Jeff 'license to kludge' Zucker, use freely at your own risk
  ###################################################################
  my($num) = @_;
  my($desired_length)=length($num);
  if( $num < 1 ) { $num = 1; } # ignore negative numbers
  $num--;
  my $pad = $desired_length - length($num);
  for ( 1 .. $pad ) { $num = "0" . $num; }
  return($num); 
}
------ end snippet ----------

HTH,

- Jeff Zucker


Michael Stearns wrote:
> 
> Hello:
> 
> I know I can do something like:
> 
> #!/usr/local/bin/perl
> $num=12;
> printf ("%.3f\n",$num);
> 
> And this will output 12.000
> 
> But what if I want to just convert the $num variable so the value
> assigned to it has three digits beyond the decimal ( in this case, 12
> to
> 12.000). Currently the calculation that create $num is removing the
> trailing zeros.
> 
> Is there a good way to assign the formatting to the variable?
> 
> (In my particular script, this would need to work no matter what the
> value of $text - 12, 12.4, 12.34, etc.)
> 
> I have one print statement in my script which has a whole mass of text
> and variables in it, including about 6 variable which I want to apply
> this formatting to. It seems like it would be difficult (at least for
> me) to construct a printf statement that would work.
> 
> Thanks,
> Michael Stearns


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

Date: 17 Sep 1998 13:58:17 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: how safe is xor encryption ?
Message-Id: <6trijp$e9f$1@monet.op.net>

In article <6trbao$6jm$1@eol.dd.chalmers.se>,
Stefan Berglund <f94stbe+news@dd.chalmers.se> wrote:
>I have to disagree as the original post <6tn6f5$h5s$1@nnrp1.dejanews.com> 
>said:

Yes, my apologies.  I made the same mistake here that I did when I
responded to Mike Gebis: I assumed that you would pack the CC# into 7
bytes before xoring it.  But the original poster was planing to xor
the *unpacked* credit card number, which is 16 bytes long, not 7.  I
answered you without making explicit that what I was thinking of was
something different from what the original poster was thinking of.

So we are both right, and the fault is mine for not making clear the
difference between the two strategies.





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

Date: 17 Sep 1998 14:08:45 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: how safe is xor encryption ?
Message-Id: <6trj7d$ee1$1@monet.op.net>

In article <3601290C.28F14002@kenan.com>,
Seth Gordon  <sgordon@kenan.com> wrote:
>Ten or twenty years ago, Unix systems would encrypt passwords using a system
>similar to yours.

I don't think so.  Originally, the passwords were unencrypted.  Later,
they were hashed the way they are now, but with a software version of
the M209 cipher machine.  More recently (But certainly for the last
twenty years) the hashing system has been based on DES.

For full details, see ``Password Security:  A Case History'' by Robert
Morris and Ken Thompson.

>Now, with a moderately fast computer and a dictionary on CD-ROM, it's
>not hard to break a file of passwords encrypted this way.

The situation with passwords is very different.  With passwords, you
have a known plaintext and a known ciphertext, and you are trying to
guess the key.  If you guess right, you know right away, because the
key turns the plaintext into the target ciphertext.  But with the
credit card numbers, you have only the ciphertext, and you want to
figure out the plaintext without the key.  If the key space is large
enough, guessing the key is  impossible because even if you guess
right you cannot be sure that you have the plaintext you want and not
something else that just looks like it.

>If you're actually building this system for commercial purposes, I strongly
>encourage you to hire a professional. 

Certainly good advice.



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

Date: Thu, 17 Sep 1998 10:56:22 -0700
From: "Felix S. Gallo" <fsg@newsguy.com>
Subject: Re: how safe is xor encryption ?
Message-Id: <6trip1$1lq@enews1.newsguy.com>


Abigail writes:
>Felix S. Gallo writes:
>++ Sociology and physics, normally.  Which is to say, imagine if
>++ your bank asked you to remember a 300 word text, or to recite
>++ a 120 letter 'random string' over the telephone.  People wouldn't
>++ accept it, even if it were truly secure (and if they did, they'd likely
>++ make errors and get mad).  Until recently, it was also surprisingly
>++ difficult to physically carry around 2 megabits.
>
>Uhm, uhm, what keeps you from creating a piece of plastic, about 4 inches
>by 2.5 inches, with a nice logo and 16 digits on it - to be used as key?

Possession of such a thing can easily be faked when purchasing over
long distances.  For instance, right after figuring out Mark-Jason's
credit card number, I just ordered fifty copies of 'Applied Cryptography'
to be delivered to his house, courtesy of Amazon.  He should've chosen
something larger than /usr/dict/words, and he should have known about
the credit card checksum.  Tsk.

ObPerl: I hereby suggest a new primitive, 'forwords', which iterates
over the contents of /usr/dict/words.  Would've saved me about 5
minutes.

Felix







p.s. psych




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

Date: Thu, 17 Sep 1998 11:43:54 -0700
From: Jian Zhang <jian@cisco.com>
Subject: How to "execute" a CGI (Perl) script inside a HTML page.
Message-Id: <3601586A.9C187ED3@cisco.com>

Hi,

I need to "execute" a short perl CGI script inside a HTML page
automatically when a page is loaded.  The script generates some
segment of of the HTML file.  My web server has been set up for CGI
support.
One way I normally "execute" server side CGI spcripts is to ask users to
hit a button:

<form action="short_scrit.pl.cgi" method = "post"><input type = "submit"

value = "text string"></form>

But now I need the CGI script "executed" automatically whenever the page
is loaded.

Please help.  Any sample code or pointers will be greatly appreciated.

Jian Zhang
San Jose, CA





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

Date: 17 Sep 1998 17:44:03 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Installing/Making on win95
Message-Id: <360149C2.DD73206A@vpservices.com>

Has anyone installed perl from source or perl modules requiring
compilation (e.g. DBI) from source on win95 using gcc or mingw32 cc? 
All the readmes and docs I can find tell me how to do this with Borland
or Microsoft c++ but I'd much rather not use them.  I tried the
cygwin.sh that comes with source but dmake didn't like it.

- Jeff


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

Date: 17 Sep 1998 18:22:09 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: internal error 500
Message-Id: <6trk0h$kbu$2@client3.news.psi.net>

Simon Ewins (sjeREMOVE@ican.net) wrote on MDCCCXLIII September MCMXCIII
in <URL: news:6trbfu$o9d$1@news2.tor.accglobal.net>:
++ I'm not sure if this is the right place to ask this but it is perl related
++ so...
++ 
++ I have a shell script which I am trying to use to get a copy of my current
++ log sent to me by e-mail from within my browser by accessing the script.
++ 
++ The sending of the log by mail is working fine but what I want to do is
++ display a web page that says so. Instead I am getting an internal error 500,
++ I think the problem is in the perl code that I have in the shell script.


What happens if you run it from the command line?
What happens if you use -w?
What happens if you use use strict;?
What is in the errorlog of your server?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Thu, 17 Sep 1998 13:01:34 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: mod function in PERL?
Message-Id: <36014E7E.F75F1B14@houston.Geco-Prakla.slb.com>

Andre L. wrote:
> 
> In article <6trave$gt8$1@client3.news.psi.net>, abigail@fnx.com wrote:
> > HTH. HAND.
> 
> Curious: what does "HAND" stand for? I'm guessing, "Hope all newbies die."
> HIW.
Maybe, but I got 'Have A Nice Day' from it.

-- 
Dave Barnett	Software Support Engineer	(281) 596-1434


My inferiority complex is not as good as yours.


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

Date: Thu, 17 Sep 1998 18:17:43 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: mod function in PERL?
Message-Id: <36014FE3.8A8F521C@bbnplanet.com>

Andre L. wrote:

> > HTH. HAND.
> 
> Curious: what does "HAND" stand for? I'm guessing, "Hope all newbies die."
> HIW.

HAND = Have a nice day. Usually used in a sarcastic 'talk to the hand'
kind of mode. 

Though, Hope all newbies die is an interesting take on it. :)

HIW?

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: Thu, 17 Sep 1998 14:28:18 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: mod function in PERL?
Message-Id: <alecler-1709981428180001@dialup-523.hip.cam.org>

In article <36014FE3.8A8F521C@bbnplanet.com>, Elaine -HappyFunBall- Ashton
<eashton@bbnplanet.com> wrote:

> Andre L. wrote:
> 
> > > HTH. HAND.
> > 
> > Curious: what does "HAND" stand for? I'm guessing, "Hope all newbies die."
> > HIW.
> 
> HAND = Have a nice day. Usually used in a sarcastic 'talk to the hand'
> kind of mode. 
> 
> Though, Hope all newbies die is an interesting take on it. :)
> 
> HIW?

Hope I'm wrong! (Which I was, fortunately.) :-]

Andre


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

Date: 17 Sep 1998 18:51:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: more regex/pattern substitution
Message-Id: <6trlo9$ldg$1@client3.news.psi.net>

Edward Glamkowski (eglamkowski@angelfire.com) wrote on MDCCCXLIII
September MCMXCIII in <URL: news:360125E1.7E17@angelfire.com>:
++ So, I have a string which may contain one or more "words" that I need
++ to upper/lower case in an odd way.  For example, PHD or Phd or phd I 
++ want to all become PhD.
++ 
++ While I could just do:
++ s/phd/PhD/ig;
++ 
++ I have several words that I want to do this to, and it would be handy
++ if I could do it all in one statement, something like:
++ s/(phd|edd)/\u\l\u$1/ig;
++ 


# Turns first and last in upper case, all else lowercase.
s/(phd|edd)/my $l = uc chop (my $s = ucfirst lc $1); $s . $l/eig;

# Idem.
s/(phd|edd)/my $s = uc $1; substr ($s => 1, -1) =~ s|(.)|lc $1|e; $s/eig;

# More flexible, allows any kind of substitution.
s/(phd|edd)/{phd => 'PhD', edd => 'EdD'} -> {lc $1}/eig;

# (Mis)Uses the fact 'phd' and 'edd' have a common suffix.
s/(ph|ed)(d)/\u\L$1\E\u$2/ig;

# Allows for capitalized suffixes of various lengths.
s/(?:(ph)(d)|(ed)(d))/ucfirst lc ($1 || $3) . uc ($2 || $4)/eig;




Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


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

Date: Thu, 17 Sep 1998 13:53:26 -0400
From: "Michael D. Hofer" <featheredfrog@geocities.com>
Subject: OT: Re: stock quote service
Message-Id: <36014C96.6A19@geocities.com>

How about:

my $symbol = 'sunw';
my $url =
"http://quote.yahoo.com/d/quotes.csv?s=$symbol&f=sl1d1t1c1ohgv&e=.csv";

and proceed from there?

Not perl, but this returns a "comma separated values" data line, and you
can easily parse and display from there...

mh (been there done that)

Michael Allen Gelman wrote:
> 
> [This followup was posted to comp.lang.perl.misc and a copy was sent to
> the cited author.]
> 
> Tom Tingdale wrote:
> > I am looking for a stock quote service that can give me this
> > information as raw data, and a Perl solution to get this data and
> > format it into a web site.
> 
> Me, too!  Tom, or anyone else, if you find this service, please email me!
> 
> My real address is my last name in front of @cheta.net
> 
> Thanks!
> 
> Sincerely,
> Michael Allen Gelman
> Amour Eternal Wedding Photography
>         ___________________________________________________________
>         Planning to get married in western North or South Carolina?
>                           http://AmourEternal.com


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

Date: Thu, 17 Sep 1998 17:53:05 GMT
From: bjohnsto_usa_net@my-dejanews.com
Subject: Re: Perl & Java - differences and uses
Message-Id: <6tria0$d95$1@nnrp1.dejanews.com>

In article <905807943.326889@thrush.omix.com>,
  Zenin <zenin@bawdycaste.org> wrote:
> bjohnsto_usa_net@my-dejanews.com wrote:

> : Database vendors offer a variety of communcations protocols now. DecNet,
IPX,
> : NetBios, TCP/IP, Shared Memory, Named pipes etc.
>
>         All of those, save for shared memory (who uses that, BTW?), are
>         private connection oriented protocols and thus fairly easy to port
>         provided the system knows how to access them.
>
> : Adding HTTP seems like a small change.
>
>         HTTP is an application level protocol built *on top* of protocols
>         such as you mention above.  It's a different layer completely.
>
>         If an "HTTP" application level protocol was built, it would likely
>         be just as slow as anything else unless the database severely cut
>         back on the amount of access control was allowed.

HTTP would be slower than the current systems for a small number of
connections with high volume.

However a protocol in which clients occasionally established a TCP/IP
connection only when they needed it would not cause the TCP/IP stack to hog
as much resources on the server as a protocol which kept the connections up
all the time.  The resources that a DB needed for a connection could drop to
a some kind of session id, current database, and current user name.

Remembering that clients are connecting to the web/application server with the
same HTTP protocol a connection directly to the database with HTTP should not
severly impact performance.

I would propose the low overhead connection as an alternative, not the only
means of access.

> : Adding a $15,000 per CPU, go on a 2 week course to learn how
> : to use it, application server seems like an expensive change.
>
>         It depends.  Most generic application servers do far, far more
>         then simply add a buffer to database calls.

They add a massive memory and speed overhead, a boatload of dependancies to
lock customers in, a mountain of bugs and idiosyncrasies.

The one I use also has an text editor from the the dark ages, a GUI SQL
generator which can not do subselects, self joins or retrieve result sets from
Oracle PL/SQL functions which return cursors.
Still its complexity help ensure that I can pay my bills I should not whine.

>         ???  True, badly designed systems using application server can be
>         inefficient, however in many apps they actually enhance performance
>         by many, many fold over "standard" access methods.

Systems based on application servers I have used perform better than a well
designed product based on cheap, well understood, industry standard products.
Actually they perform much worse.

> : Are you optimising programmer time like this?
>
>         Yes.  Efficient runtime and efficient development do not have to be
>         at odds.  Granted, it takes more still and experience, but for those
>         that can do it well it's very beneficial. -Remember, if there is
>         an efficiency problem later you may be required to go in after the
>         fact to fix it, and in many cases this can require major
>         architecture changes that cost far more then if they were worked
>         out before hand.

I tend to agree with you here.

[snip agree reusable modules can be less efficient than the optimal special
purpose code]

>         The particular task being basic mail serving, in a high load
>         situation.  This is something any stock Unix boxes should be able
>         to handle with little to no changes to the basic mail config.

The crucial p[art of the application is server the advertisments not the mail
:-).


> : If there was a
> : substantial requirement for changes in Hotmail which required a rewrite
> : anyway, then the rewwrite would most likely occur on NT.
>
>         *Only* because they were bought by MS, and for no technical merit
>         of NT.

Absolutely.

>         Microsoft.com is on *rooms* of NT servers.  It's huge.  It's a
>         living testimonial that if you throw enough hardware at nearly any
>         OS you can handle big loads.

Agree completely.  This is an important point.


[snip my irrelevant point]

>         Last I checked, MS still recommended running no more then one
>         major service per box.
>
>         If ten Unix servers where all running file servers, databases,
>         web servers, and FTP servers, it's likely that one admin would
>         be all that's needed.

I have never had any difficulty evolving into being able to manage NT servers,
using only 1% of my time.
I feel that unix would require me to take a big leap.  This leap may be worth
it.  But the evolution into being NT literate was quite painless.

[snip]

> : Don't know python.  I assume you are talking about its intrepreted nature,
and
> : pure OO design.
>
>         The interpreted nature isn't a problem; I consider it an asset
>         actually.  It's heavy "OO only" and "one true, correct way" bent is
>         what I was speeking to.
>
> : However I mostly find that when performance is inadequate it is because of
> : excess calls to an external library or resource, not coding inefficiencies.
>
>         I envy you in this case.  There is quite a bit of OOO (Overly OO)
>         code around CPAN and the computer world at large, much leading to
>         highly complex and inefficient code that are monuments to
>         abstraction gone horribly wrong...


I late/runtime binding is quite useful, I have seen a number of systems that
could benefit from a design which uses it.  I am hoping hardware help makes it
cheap the way floating point is now cheap.
Still enough heap operations can definitely impact performce.

>
>         >snip<
> : >         It's not just that issue.  It's also the simple fact that work
> : >         should be done where the data is.
> : This has always been true.  'Client/Server database' tools like VB,
> : Powerbuilder, and SQL Windows still put all the code on the client.
>
>         One more reason I'll stay on Unix, thanks. :-)

I suspect that Unix has no tools with generate server based programs as easily
as VB can generate client side code.
Win32 developers seem to have a broader range of choices.

> : Anything which raises the, already high, costs of software development is
> : going to be a problem.
>
>         That's the thing, it doens't (or shouldn't at least).  It can
>         actually be the other way around.  I'm not talking about slaving
>         away over a hot terminal for hours trying to shave away 3 clock
>         ticks.  I'm just speeking of the difference in fundamental design
>         when the programmer actually knows what's going on under the hood.
>
>         They need to know what happends when a function is called.  They
>         need to know why a method is more expensive then a function.  They
>         need to understand the pros and cons of inlining.  They need to
>         know how expensive string to int conversions really are and why, even
>         if the language or system (such as Oracle) they are working in makes
>         the action transparent.  They need to understand how data is really
>         stored in memory and why it is expensive to move it around.

I have understood all this.  And have since 1990.
I have suffered plenty of lessons on performance since.

>         They
>         need to understand context switching, and why 300 children
>         select()ing or accept()ing on the same descriptor is very
>         expensive.

On an unrelated subject I thought I might have found a use for select and
could not get it to work. I want a server check if there is any input from
administrators on stdin without blocking while doing other stuff. I copied
the code for select from the camel book (which is also for stdin) and it
always returned the same thing, whether of not there was any input.

    $rin = $win = $ein = "";
    vec($rin, fileno(STDIN), 1) = 1;
    vec($win, fileno(STDOUT), 1) = 1;
    $ein = $rin | $win;
    ($nfound, $timeleft) = select($rout = $rin, $wout=$win, $eout=$ein, 0);
    print ("Found $nfound, Timeleft $timeleft\n\n");

prints - Found -1, Timeleft 0

Any Clues?

>
>         Such low level understanding is what separates the good from the
>         great, and such understanding should not impact the development
>         time.  In many cases, it will shorten it in the long run as
>         many efficiency problems that would normally need to be fixed later
>         will simply never happen.

> -Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:


For what is worth I think what separate the good from the great is being able
to really understand the problem and see simple solutions.  Low level
understanding it only one building block to help see what is and what is not
a solution. The precise qualities that separate the good from the great will
change all the time.

Java and Perl's greatness as languages would have been for nought if it were
not for the internet creating new niches for mobile secure code and server
based text processing.	Perl is quite capable as a scripting language, but
its explosive growth does not come from this alone.

Brendan Johnston


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 17 Sep 1998 12:55:53 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: mwoog@pobox.ch
Subject: Re: Removing double entries from array
Message-Id: <36014D29.15ACAA93@houston.Geco-Prakla.slb.com>

[courtesy cc to cited author]


Marc-A. Woog wrote:
> 
> Hi
> 
> I am quite new to Perl and I have a "How-to-do-better"-Question:
> 
> I have tons of entries in @url_list, sometimes two or more times the
> same. I want to remove all redundant entries and this is the code I
> came up 'til now:
> 
> foreach $url (@url_list) {
>   $flag = 1;
>   foreach (@temp_url_list) {
>     if ( $_ eq $url) {
>       $flag = 0;
>       next;
>     }
>   }
> if ( $flag == 1 ) { push (@temp_url_list, $url); }
> }
> @url_list = @temp_url_list;
> 
Hashes are great for unique lists of values.  Create a hash with the
entry you want to be unique as the key (the url in this case).

Try this:
#!/usr/local/bin/perl -w
#
use Benchmark;
 
my $count = 50000;
 
@url_list = qw (one.com two.com three.com
    four.com one.com two.com three.com
    four.com one.com two.com three.com
    four.com one.com two.com three.com
    four.com one.com two.com three.com
    four.com one.com two.com three.com
    five.com six.com seven.com eight.com);
 
my %hash;
 
timethese($count, {
    'Hash' => sub {
        foreach my $url (@url_list) { # Take this line
          $hash{"$url"}++;            # this line
        }                             # and this line
    },
    'Array' => sub {
        foreach my $url (@url_list) {
          $flag = 1;
          foreach (@temp_url_list) {
            if ( $_ eq $url) {
              $flag = 0;
              next;
            }
          }
          if ( $flag == 1 ) { push (@temp_url_list, $url); }
        }
        @url_list = @temp_url_list;
    }
    }
);
print "Array:\n\n";
foreach (@url_list) {
    print $_, "\n";
}
 
print "\n\nHash:\n\n";
foreach (sort keys %hash) {
    print $_, "\n";
}
__END__

Provides some interesting results:
Benchmark: timing 50000 iterations of Array, Hash...
     Array: 25 secs (24.33 usr  0.00 sys = 24.33 cpu)
      Hash:  4 secs ( 3.86 usr  0.00 sys =  3.86 cpu)


Should save you a fair amount of time.

These four lines can replace all of the code you gave for your example:
	my %hash;
	foreach my $url (@url_list) {
	    $hash{"$url"}++;
	}


> Is there a more elegant and efficient (meaning faster) way to do the
> same (this looks more like basic than perl to me)?
The Benchmark module is good for determining this type of thing (see
above).
 
> THX in advance,
> 
> Marc
> 
> --
> Marc-A. Woog
> mwoog@pobox.ch
> http://www.dtc.ch/mwoog/
HTH.

Cheers,
Dave

-- 
Dave Barnett	Software Support Engineer	(281) 596-1434


If you're born again, do you have two belly-buttons?


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

Date: Thu, 17 Sep 1998 18:51:50 GMT
From: mwoog@pobox.ch (Marc-A. Woog)
Subject: Re: Removing double entries from array
Message-Id: <360659d5.31284386@news.datacomm.ch>

On Thu, 17 Sep 1998 12:55:53 -0500, Dave Barnett
<barnett@houston.Geco-Prakla.slb.com> wrote:

[...]
>Provides some interesting results:
>Benchmark: timing 50000 iterations of Array, Hash...
>     Array: 25 secs (24.33 usr  0.00 sys = 24.33 cpu)
>      Hash:  4 secs ( 3.86 usr  0.00 sys =  3.86 cpu)
>Should save you a fair amount of time.
[...]

Goes off like a rocket. I can't read the screen output anymore. Is
there a way to make it slower again? ;)

BTW, sadly enough the Benchmark-Thing won't run on my Perl Win32
("...time not implemented..."). Another hint to change to Linux?

Anyhow, problem solved, case closed!

THX to all who responded,

Marc

-- 
Marc-A. Woog
mwoog@pobox.ch
http://www.dtc.ch/mwoog/


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

Date: Thu, 17 Sep 1998 14:36:08 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Removing double entries from array
Message-Id: <6trkqo$br7$1@earth.superlink.net>

Dave Barnett <barnett@houston.Geco-Prakla.slb.com> writes:


>Marc-A. Woog wrote:

>> I have tons of entries in @url_list, sometimes two or more times the
>> same. I want to remove all redundant entries and this is the code I
>> came up 'til now:
>> 
>> foreach $url (@url_list) {
>>   $flag = 1;
>>   foreach (@temp_url_list) {
>>     if ( $_ eq $url) {
>>       $flag = 0;
>>       next;
>>     }
>>   }
>> if ( $flag == 1 ) { push (@temp_url_list, $url); }
>> }
>> @url_list = @temp_url_list;
>> 
>Hashes are great for unique lists of values.  Create a hash with the
>entry you want to be unique as the key (the url in this case).

[snip]

>timethese($count, {
>    'Hash' => sub {
>        foreach my $url (@url_list) { # Take this line
>          $hash{"$url"}++;            # this line
>        }                             # and this line
>    },

[snip]

>Provides some interesting results:
>Benchmark: timing 50000 iterations of Array, Hash...
>     Array: 25 secs (24.33 usr  0.00 sys = 24.33 cpu)
>      Hash:  4 secs ( 3.86 usr  0.00 sys =  3.86 cpu)


>These four lines can replace all of the code you gave for your example:
>	my %hash;
>	foreach my $url (@url_list) {
>	    $hash{"$url"}++;
>	}

And if you're *really* in a hurry, try:

undef %hash;
@hash{@url_list} = ();

(Keys of %hash now contain unique array elements.  See perlfaq4.)

Benchmark: timing 50000 iterations of Hash, Hash2...
      Hash: 29 wallclock secs (27.98 usr +  0.10 sys = 28.08 CPU)
     Hash2: 14 wallclock secs (13.26 usr +  0.05 sys = 13.31 CPU)


David Black
dblack@saturn.superlink.net


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

Date: Thu, 17 Sep 1998 20:27:02 +0200
From: Antonio Alves <alves@business-village.com>
Subject: Re: SSI , Perl and IIS
Message-Id: <36015476.914A16E4@business-village.com>



Cristovao Morgado wrote:

> I am trying to make some perl scripts to use on IIS.
> Is I call the script : x.pl that is:
>
> print "Content-type: text/html\n \n";
> print "teste";
>
> with a form it works
>
> if i use <!-- #exec cgi="x.pl" -->
> on a xx.shtm file I get the fowling message :
> HTTP/1.1 200 OK Date: Thu, 17 Sep 1998 16:53:08 GMT Server:
> Microsoft-IIS/4.0 Content-type: text/html
> 'd:\Inetpub\wwwroot\teste\2.shtm' script produced no output

>
> Does any1 knows what i'm doing wrong ?
> It should return : teste
> Why on SSI it says that ?
>
> Thx in advanced
> Cristovao Morgado

first, Did you put the 2 files in a directory you can execute ?
and,
are you sure that the extension for SSI file is .shtm in IIS
By default I have .stm

Tonio




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

Date: Thu, 17 Sep 1998 18:42:18 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: stock quote service
Message-Id: <opgaf3y1sz9.fsf@harper.uchicago.edu>

nospam@cheta.net (Michael Allen Gelman) writes:

> 
> [This followup was posted to comp.lang.perl.misc and a copy was sent to 
> the cited author.]
> 
> Tom Tingdale wrote:
> > I am looking for a stock quote service that can give me this
> > information as raw data, and a Perl solution to get this data and
> > format it into a web site.
> 
> Me, too!  Tom, or anyone else, if you find this service, please email me!

Check out www.isld.com

-- 
Peter A Fein                                           Summering in SF!
Home:                                                Work: 650-628-2172
p-fein@uchicago.edu                             pfein@us.checkpoint.com
Let the fucking elk do it. --Grey Claw


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

Date: Thu, 17 Sep 1998 18:32:34 GMT
From: mc <lesaber@hotmail.com>
Subject: Where is TIX?
Message-Id: <360155C2.7BC0@hotmail.com>

It appears that the xpi site is down (maybe permanently) is TIX still
available, and if so where is it?


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3742
**************************************

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