[7885] in Perl-Users-Digest
Perl-Users Digest, Issue: 1510 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 19 16:09:25 1997
Date: Fri, 19 Dec 97 13:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 19 Dec 1997 Volume: 8 Number: 1510
Today's topics:
Beginning Perl Prog Tutorilal - Boulder, CO <johnd@xor.com>
Re: DEBUGGER: How see expr result ? <Tim.Maher@seaslug.org>
Re: DEBUGGER: How see expr result ? <rootbeer@teleport.com>
Re: Happy Birthday Perl ? <uzs7ci@ibm.rhrz.uni-bonn.de>
Re: Happy Birthday Perl ? <tycage@infi.net>
Re: Happy birthday Perl! <#@qz.to>
Help with calculating Gunning (reading level) index for (Bass Player)
Re: HELP: Advice on (global) destruction (REPOST) <paul@nospam.miraclefish.com>
HELP: Advice on (global) destruction <o@p.q>
Re: HELP: Advice on (global) destruction <rootbeer@teleport.com>
Re: hey guyz! plz help me out! (brian d foy)
Re: hey guyz! plz help me out! (Michael Budash)
Re: hey guyz! plz help me out! (brian d foy)
How do I Access the Integer Returned by a C Program? (Kevin M Simonson)
Re: Inheritance question (Honza Pazdziora)
Re: Inheritance question <reibert@mystech.com>
Re: Newbie Pattern Matching question <reibert@mystech.com>
OLE with perl5, problems (Kjetil Skotheim)
Re: Perl for windows 3.1 <jvradelis@mediaone.net>
Re: Problem with socket upon HTTP <tchrist@mox.perl.com>
Re: Problem with socket upon HTTP <mdgoutte@asi.fr>
Re: Problem with socket upon HTTP <mdgoutte@asi.fr>
Randomize the order of an array (Bob Stewart)
Re: Re : access to file other than in cgi dir. <#@qz.to>
Scanning the access_log file <dgoyette@NoMoreSPAMpcisys.net>
Re: Sending a signal to a process owned by someone else <#@qz.to>
Statistics::Descriptive yields error in AUTOLOAD <brannon@surf.usc.edu>
Re: Whats wrong with this simple code? (Andrew M. Langmead)
Re: Whats wrong with this simple code? (Mike Stok)
Re: Whats wrong with this simple code? (brian d foy)
Re: Which language pays most 17457 -- C++ vs. Java? <robert.garskof@snet.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Dec 1997 11:51:04 -0700
From: John Donnelly <johnd@xor.com>
Subject: Beginning Perl Prog Tutorilal - Boulder, CO
Message-Id: <349AC218.5747@xor.com>
**Upcoming (January '98) Tutorial**
Session is held at our training facility in Boulder, CO.
Class size is limited to 10 people.
Contact me for further information, registration forms.
--John Donnelly, Training Coordinator
XOR Network Engineering, Inc.
http://www.xor.com/tt johnd@xor.com 303-448-4816
*****
Beginning Perl Programming
(Three Day Hands-on Lecture/Lab)
Tom Christiansen, Consultant
Tuesday-Thursday, January 13-15, 1998
*****
------------------------------
Date: Fri, 19 Dec 1997 09:43:21 +0000
From: Tim Maher <Tim.Maher@seaslug.org>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: DEBUGGER: How see expr result ?
Message-Id: <349A41B9.6E815F28@seaslug.org>
Ilya Zakharevich wrote:
> In article <349938EB.89BE0BCB@timji.seaslug.org>,
> Tim Maher <tim@timji.seaslug.org> wrote:
> > So in Perl, when the debugger has just evaluated the following:
> > s/abc/def/g # how many subs did it do?
> > (stuff deleted)
> > how can I directly see the result ?
>
> If it is assigned to something, you may e`x'amine this something.
> Otherwise it is executed in void context, thus will not return
> anything.
That strikes me as pretty bad! So I have to rewrite my program to do a
superfluous
scalar assignment just so later when I'm debugging it I can see what's
going on?
>
>
> > In a similar vein, when it hits a sub return statement, I see the
> > expression that
> > calculates the return value, but I don't get to see the return value
>
> > itself! There
> > must be a way . . .
>
> See documentation for `r' command. But again, it will not work in
> void context.
>
> Ilya
Funny, there's no mention of the "r" command in the debugging chapter of
the Camel
book! And all I can find in "perldebug" is the following :
PrintRet: affects printing of return value after r command
If the documentation of the r command is in that man page, I can't find
it! Can
somebody give me an RE to help me search to the right spot?
--
====================================================================
| Tim Maher, Ph.D. Tel/Fax: (206)781-UNIX |
| Head UNIX Guru, CONSULTIX Email: tim@consultix.wa.com |
| *The UNIX Training Experts* http://www.consultix.wa.com/yumpy/ |
====================================================================
------------------------------
Date: Fri, 19 Dec 1997 10:26:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Tim Maher <Tim.Maher@seaslug.org>
Subject: Re: DEBUGGER: How see expr result ?
Message-Id: <Pine.GSO.3.96.971219102435.23972p-100000@user2.teleport.com>
On Fri, 19 Dec 1997, Tim Maher wrote:
> > Otherwise it is executed in void context, thus will not return
> > anything.
>
> That strikes me as pretty bad! So I have to rewrite my program to do a
> superfluous scalar assignment just so later when I'm debugging it I can
> see what's going on?
Yes. Otherwise you're trying to see the inside of a lump of coal. When you
break a lump of coal open, you find you're still looking at the outside!
There _is_ no value if something was evaluated in a void context. If you
want a value, you must supply a different context.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 19 Dec 1997 19:13:46 +0100
From: Oliver Much <uzs7ci@ibm.rhrz.uni-bonn.de>
Subject: Re: Happy Birthday Perl ?
Message-Id: <67edgq$1h2@walras.econ.de>
Tom Phoenix <rootbeer@teleport.com> wrote:
>> Is it true that Perl celebrated its 10th anniversary on 12/18/97 ?
TP>Yes, Perl 1.0 was released ten years ago, now. If you're still running
TP>that version, it's time to upgrade.
Nah, I'd rather start my time-machine and travel back in time. Where did
Larry live in these days ? Adress ?
--
---
Oliver Much|@home: UZS7CI@ibm.rhrz.uni-bonn.de | Sei P ein Punkt Q wir
|@work: oliverm@addi.finasto.uni-bonn.de| wollen ihn Z nennen.
------------------------------
Date: Fri, 19 Dec 1997 15:03:24 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Happy Birthday Perl ?
Message-Id: <349AD30C.25DC3611@infi.net>
Tom Phoenix wrote:
>
> On 18 Dec 1997, Oliver Much wrote:
>
> > Is it true that Perl celebrated its 10th anniversary on 12/18/97 ?
>
> Yes, Perl 1.0 was released ten years ago, now. If you're still running
> that version, it's time to upgrade.
That's right. It's not Y2K compliant. =)
+---+
Ty Cage Warren tycage@infi.net
Systems Engineer InfiNet
Homepage: http://tazer.engrs.infi.net/~tycage
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: 19 Dec 1997 20:43:20 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Happy birthday Perl!
Message-Id: <eli$9712191540@qz.little-neck.ny.us>
Keywords: sponsored by the letters C, F, K, and U
the count <eglamkowski@angelfire.com> wrote:
> So, what's everybody's favorite feature of perl?
Two words: regular fucking expressions.
Elijah
------
#!/usr/bin/perl -- -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P&,\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;
------------------------------
Date: Fri, 19 Dec 1997 18:05:59 GMT
From: fenderbass@evang.com (Bass Player)
Subject: Help with calculating Gunning (reading level) index for documents
Message-Id: <67ecn8$co6$1@news2.ispnews.com>
I am trying to determine the reading grade level (Gunning FOG Index) of a text
document. I do have the calculation, but I ran into a snag....
$a=any 100 word block
$b=number of sentences in $a
$c=number of words in $a having over 3 syllables.
$GFI = int(( (100/$b) + $c) *0.4 ))
The biggest stumbling block is trying to determine the number of syllables in
a particular word. Anyone got any help on this?
Blake
------------------------------
Date: Fri, 19 Dec 1997 18:11:05 +0000
From: Paul <paul@nospam.miraclefish.com>
Subject: Re: HELP: Advice on (global) destruction (REPOST)
Message-Id: <349AB8B9.533C1635@nospam.miraclefish.com>
Same as before but with a more appropriate email address for responses ;-)
O wrote:
> I'm having some problems using destructors in an OO module I'm
> developing. I'll try to make the description as concise as possible and
> would really appreciate expert advice from anyone who makes it thtrough
> to the end.
>
> Here's a schematic of the pertinent classes from a system to add
> persistency to Perl using a relational database (Mysql) to store the
> data items.
>
> Persistent.pm
> ^
> ||
> PersistentThing.pm---(class data)--->Table.pm|--->[ Column.pm ]
>
> |--->PrimaryKey.pm
>
> Subclasses of Persistent.pm have a class variable $table --- an object
> in its own right --- describing the table in which to store the data
> intems from objects, one per row. The DESTROY method in Persistent.pm
> updates the associated table with the current values of the fields.
>
> The planned usage is that data items in persistent objects will be used
> to update the corresponding rows in the associated table when the object
> is DESTROYed. The PrimaryKey object is used to form an SQL WHERE clause
> using the value of the data item matching the key field to ensure that
> only one row per object is updated. When a program which makes use of
> persistent objects exits the final garbage collection pass should call
> each of the persistent objects DESTROY methods which will update the
> tables in the database.
>
> This is where the problem occurs. The primary key of the associated
> table appears to be correctly set just before the program exits.
> However during the garbage collection when an object tries to use it to
> look up the primary key it is no longer there! The only explanation I
> have for this is that the garbage collection is DESTROYing the
> PrimaryKey object *before* it DESTROYs the (persistent) object that
> requires it.
>
> Have I made the mistake of relying on the order in which the garbage
> collector destroys objects? Can you suggest another approach?
>
> Paul
------------------------------
Date: Fri, 19 Dec 1997 18:05:07 +0000
From: O <o@p.q>
To: bjepson@ids.net
Subject: HELP: Advice on (global) destruction
Message-Id: <349AB753.AFE9939@p.q>
I'm having some problems using destructors in an OO module I'm
developing. I'll try to make the description as concise as possible and
would really appreciate expert advice from anyone who makes it thtrough
to the end.
Here's a schematic of the pertinent classes from a system to add
persistency to Perl using a relational database (Mysql) to store the
data items.
Persistent.pm
^
||
PersistentThing.pm---(class data)--->Table.pm|--->[ Column.pm ]
|--->PrimaryKey.pm
Subclasses of Persistent.pm have a class variable $table --- an object
in its own right --- describing the table in which to store the data
intems from objects, one per row. The DESTROY method in Persistent.pm
updates the associated table with the current values of the fields.
The planned usage is that data items in persistent objects will be used
to update the corresponding rows in the associated table when the object
is DESTROYed. The PrimaryKey object is used to form an SQL WHERE clause
using the value of the data item matching the key field to ensure that
only one row per object is updated. When a program which makes use of
persistent objects exits the final garbage collection pass should call
each of the persistent objects DESTROY methods which will update the
tables in the database.
This is where the problem occurs. The primary key of the associated
table appears to be correctly set just before the program exits.
However during the garbage collection when an object tries to use it to
look up the primary key it is no longer there! The only explanation I
have for this is that the garbage collection is DESTROYing the
PrimaryKey object *before* it DESTROYs the (persistent) object that
requires it.
Have I made the mistake of relying on the order in which the garbage
collector destroys objects? Can you suggest another approach?
Paul
------------------------------
Date: Fri, 19 Dec 1997 10:30:51 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: O <o@p.q>
Subject: Re: HELP: Advice on (global) destruction
Message-Id: <Pine.GSO.3.96.971219102733.23972q-100000@user2.teleport.com>
On Fri, 19 Dec 1997, O wrote:
> The only explanation I have for this is that the garbage collection is
> DESTROYing the PrimaryKey object *before* it DESTROYs the (persistent)
> object that requires it.
>
> Have I made the mistake of relying on the order in which the garbage
> collector destroys objects?
Sure sounds like it. If you want object FOO to be around after object BAR
is destroyed, one way is to keep a ref to FOO within BAR. Just don't have
a reference to BAR within FOO as well. :-) Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 19 Dec 1997 13:09:13 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: hey guyz! plz help me out!
Message-Id: <comdog-ya02408000R1912971309130001@news.panix.com>
Keywords: from just another new york perl hacker
In article <349AD6A0.26A9FB7@ica.net>, Alex Kovalenko <luckycom@ica.net> wrote:
>i am recently in perl, so i am have some faq ques...
then the FAQs might be a good place to go.
>1) i need to make up a cgi script which will do the following:
>I have several forms on my Web Page like : name, password, ID, and
>etc...
take a look at the CGI.pm module. questions specific to CGI can
be asked in comp.infosystems.www.authoring.cgi
good luck :)
--
brian d foy <comdog@computerdog.com>
Meta Meta FAQ <URL:http://computerdog.com/Meta_MetaFAQ.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Fri, 19 Dec 1997 11:31:17 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: hey guyz! plz help me out!
Message-Id: <mbudash-1912971131170001@d203.pm13.sonic.net>
In article <349AD6A0.26A9FB7@ica.net>, Alex Kovalenko <luckycom@ica.net> wrote:
>> hey there programmerz...
>> i am recently in perl, so i am have some faq ques...
>> 1) i need to make up a cgi script which will do the following:
>> I have several forms on my Web Page like : name, password, ID, and
>> etc...
>> then i need that perl script take all of those and put it in the form
>> like :
>> Alex Kovalenko
>> security
>> 1234567890
>> and etc.
>>
>> then i need that this script SEND ALL OF THIS to e-mail and also ADD all
>> this information to file called for example users.dat ...
>>
you might try selena sol's form processor script
(http://www.fukada.com/selena/Scripts/scripts.html) - i think it'll do all
you ask (and more).
good luck
--
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736
------------------------------
Date: Fri, 19 Dec 1997 15:35:26 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: hey guyz! plz help me out!
Message-Id: <comdog-ya02408000R1912971535260001@news.panix.com>
Keywords: from just another new york perl hacker
In article <mbudash-1912971131170001@d203.pm13.sonic.net>, mbudash@sonic.net (Michael Budash) wrote:
>you might try selena sol's form processor script
>(http://www.fukada.com/selena/Scripts/scripts.html) - i think it'll do all
>you ask (and more).
that's a very old and somewhat monstrous way to accomplish such a
simple task. i even noticed a race condition in his lock file
routine, which could lead to database corruption, although i doubt this
would happen on an infrequently visited site.
one of my programmers absolutely detests working with some of Selena
Sol's scripts because the configuration files are Perl code - make a
syntax error in a configuration file and the entire script bombs. this
is not a good way to handle configuration files, especially when your
market might be non-perl programmers.
however, all of Selena's stuff is well commented - perhaps the best
commentary in code that i have ever seen. throw away the code and you
have a pretty good discussion of what you need to think about to solve
the problem, even if there were a few implementation issues that were
not resolved correctly.
--
brian d foy <comdog@computerdog.com>
Meta Meta FAQ <URL:http://computerdog.com/Meta_MetaFAQ.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 19 Dec 1997 20:42:59 GMT
From: simonsen_nospam@skopen.dseg.ti.com (Kevin M Simonson)
Subject: How do I Access the Integer Returned by a C Program?
Message-Id: <67em8j$hsb@sf18.dseg.ti.com>
Keywords: c program integer access
I've written a little C program that just subtracts two from the num-
ber of its arguments and then returns that value to its calling environ-
ment. I'm running this on a Unix platform, so this value gets put into the
"status" variable as illustrated:
i48^Nag/Source} ReturnValue
Read in 1 arguments, so returning -1.
i48^Nag/Source} echo $status
-1
i48^Nag/Source} ReturnValue a
Read in 2 arguments, so returning 0.
i48^Nag/Source} echo $status
0
i48^Nag/Source} ReturnValue a b
Read in 3 arguments, so returning 1.
i48^Nag/Source} echo $status
1
i48^Nag/Source}
I need to get some information from a C program to the "perl" script
that is going to call it, so I decided to test this out with a "perl"
script that calls "ReturnValue". Here's the one I wrote:
#!/usr/local/bin/perl
print "ReturnValue @ARGV\n";
print `ReturnValue @ARGV`;
if ($status == 0)
{ print "Status was zero.\n";
}
else
{ print "Status was $status.\n";
}
However, when I run this on the same series of command line arguments,
here's what I get:
i48^Nag/Source} Crv_PerlStatus
ReturnValue
Read in 1 arguments, so returning -1.
Status was zero.
i48^Nag/Source} Crv_PerlStatus a
ReturnValue a
Read in 2 arguments, so returning 0.
Status was zero.
i48^Nag/Source} Crv_PerlStatus a b
ReturnValue a b
Read in 3 arguments, so returning 1.
Status was zero.
i48^Nag/Source}
Anybody know what I'm doing wrong here? Perhaps more to the point,
can anyone tell me how I can use "perl" to access the value returned to the
calling environment by a C program?
If anyone would like to see the source for "ReturnValue" I could cer-
tianly provide it, though it seems irrelevant to the problem.
---Kevin Simonson
-------------------------------------------------------------------------
Reverence To send me mail, remove "_nospam" and
the eternal. all the vowels from my login name.
------------------------------
Date: Fri, 19 Dec 1997 18:08:55 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Inheritance question
Message-Id: <adelton.882554935@aisa.fi.muni.cz>
%%Kenneth_Lee%%@pcmailgw.ml.com (Kenneth Lee) writes:
[...]
> It seems to compile well enough, except that when I attempt something like
> this:
>
> $q = new SecurePage;
> $q->param(-Name=>'foo', -Value=>'bar');
>
> I end up with the runtime error:
> Can't locate object method "param" via package "SecurePage" at
> SecurePage.pm line.....
>
> Am I not performing the inheritance correctly? Shouldn't CGI's methods
> become inherited by SecurePage? If so, why can't I access them in the
> expected manner?
I had similar problem I week or so ago. I have written to Lincoln and
I hope he wouldn't mind if I quote his reply:
> unfortunately, a couple of tricks that you must use to inherit
> successfully from CGI.pm without breaking the autoload mechanism. You
> can see the tricks by looking at the definition of CGI::Apache (two
> package globals you must set named DefaultClass and AutoloadClass).
Hope this will help,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Fri, 19 Dec 1997 12:15:16 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: Inheritance question
Message-Id: <349AC7C4.D7424266@mystech.com>
Kenneth Lee wrote:
> The header for SecurePage.pm looks like:
>
> package Secure_Page;
> use CGI;
> use Sybase::CTlib;
> use Exporter;
> use strict;
> require 'Web_Profile.pl';
>
> @ISA::Secure_Page = qw(CGI CTlib Exporter);
I think things will work if you change the above to
@ISA = qw(CGI CTlib Exporter);
HTH
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: Fri, 19 Dec 1997 11:55:38 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: Newbie Pattern Matching question
Message-Id: <349AC32A.BB737A38@mystech.com>
Clinton Bodine wrote:
> Or how about??
>
> $line = "the dog (big) ran home";
> $line =~ /\((.*?)\)/;
> $line = $1;
>
Actually, that was my first thought, but I rewrote to avoid the minimal match.
It's my understanding that minimal matching is slow because after each character
the algorithm has to "jump" out and see if the remaining string can match what's
left. (That thought is much more clear in my mind! :-)
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: 19 Dec 1997 18:34:45 GMT
From: kjetil.skotheim@usit.uio.no (Kjetil Skotheim)
Subject: OLE with perl5, problems
Message-Id: <67eeo5$dc3$2@ratatosk.uio.no>
I've installed perl5 for win95 from www.activestate.com
The documentation says that the following sniplet should be
able to "manipulate" Excel:
use OLE;
$excel = CreateObject OLE 'Excel.Application'
or warn "Couldn't create new instance of Excel App!!";
$excel->Workbooks->Open( 'test.xls' );
$excel->Workbooks(1)->Worksheets('Sheet1')->Cells(1,2)->{Value} = 'foo';
$excel->Workbooks(1)->Worksheets('Sheet1')->Cells(1,2)->{Value} = 'bar';
$excel->Save(); $excel->Quit();
This does not work! At Open the program dies with this message:
Can't call method "Open" without a package or object reference
at c:\perl\test\oletest.pl line 5.
Ctrl-alt-del shows that an excel process is being created
(but it is impossible to turn it visible).
Anyone ever got something with OLE to work? Did you do anything special?
Hints?
--
Kjetil Skotheim
------------------------------
Date: Fri, 19 Dec 1997 14:56:26 -0500
From: "James T. Vradelis" <jvradelis@mediaone.net>
To: sserebry@tuc.com
Subject: Re: Perl for windows 3.1
Message-Id: <349AD16A.AF33FBF@mediaone.net>
Try CPAN. (you can go to www.perl.org and follow links to get there).
There is a port that purports (sorry) to run in DOS and Win3.1, but I
haven't tried it. I think it's actually an OS/2 port.
------------------------------
Date: 19 Dec 1997 17:15:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Problem with socket upon HTTP
Message-Id: <67ea46$166$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, mdgoutte@asi.fr writes:
:send (S,"GET $file HTTP/1.0 \n",0) ;
send()? What?
print S "GET $file HTTP/1.0\n\n";
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"I never met a chocolate I didn't like."
--Deanna Troi, ST:TNG
------------------------------
Date: Fri, 19 Dec 1997 20:10:20 +0100
From: Dominique et Marc de GOUTTES <mdgoutte@asi.fr>
Subject: Re: Problem with socket upon HTTP
Message-Id: <349AC69C.4DA7@asi.fr>
Tom Christiansen wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, mdgoutte@asi.fr writes:
> :send (S,"GET $file HTTP/1.0 \n",0) ;
>
> send()? What?
>
> print S "GET $file HTTP/1.0\n\n";
>
> --tom
> --
> Tom Christiansen tchrist@jhereg.perl.com
>
> "I never met a chocolate I didn't like."
> --Deanna Troi, ST:TNG
OK, sorry, I should have said that I've already tryied to work with
my socket using *print S* instead of *send(S* and using *=<S>* instead
of
*recv*. With the same result. I think the problem is not here.
Thanks for your help.
------------------------------
Date: Fri, 19 Dec 1997 20:24:39 +0100
From: Dominique et Marc de GOUTTES <mdgoutte@asi.fr>
Subject: Re: Problem with socket upon HTTP
Message-Id: <349AC9F7.19A4@asi.fr>
brian d foy wrote:
>
> are you sure it works with every host.? checking for warnings by
> invoking perl as
>
> #!/usr/bin/perl -w
>
> will tell you about some problems.
>
OK, PERL told me about some problems, but none of them seems to explain
why it doesn't work with www.yslaire.be. I've put my script to its
original form, as shown below, and I'm sorry to say it gave me the same
result.
----------------------------------------------------------------------------------
# browserspl.pl : simple browser
use Socket;
if ($#ARGV != 0) {
print "Usage : $0 HOST[:PORT]/[URL]\n" ;
exit 1 ;
}
($host,$file) = split (/\//,$ARGV[0]) ;
$file = "/$file" ;
($host,$port) = split (/:/,$host) ;
if ( $port eq "" ) { $port = 80 ; }
$sockaddr = 'S n a4 x8';
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $type, $len, $thataddr) = gethostbyname($host);
$that = pack($sockaddr, AF_INET, $port, $thataddr);
socket(S, AF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(S, $that) || die "connect: $!";
select(S); $| = 1; select(STDOUT);
print S ("GET $file HTTP/1.0 \n") ;
print S ("Connection: Keep-Alive\n") ;
print S ("User-Agent: Mozilla/3.0Gold (Win95; I)\n") ;
print S ("Host: $host\n") ;
print S ("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
*/*\n") ;
print S ("\n") ;
while ($lig = <S>) {
print "$lig" ;
}
close (S) ;
---------------------------------------------------------------------------------------------------
In fact, it works very well, except with this haunted host in Belgium...
------------------------------
Date: Fri, 19 Dec 1997 20:38:49 GMT
From: editor@gardenweb.com (Bob Stewart)
Subject: Randomize the order of an array
Message-Id: <349ada25.480603@news.digex.net>
I want to take amn array of listings and have them display in a
different order each time someone accesses a script. The randomness
does not need to be truely random.
What I have is a directory of company names. I want to set it up so
they are not always listed A-Z, or someother set order, but in a
fairly random way so that someone accessing the script on two
different days is likely to see things in a different order.
Is there an easy way to do this?
Thanks!
Bob Stewart
editor@gardenweb.com
------------------------------
Date: 19 Dec 1997 20:37:21 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Re : access to file other than in cgi dir.
Message-Id: <eli$9712191528@qz.little-neck.ny.us>
A. Warnier <100606.1753@compuserve.com> wrote:
> Hi.
> I'm newbie to newsgroups (also), so maybe this posting will not "thread"
> correctly.
It would seem so. I have no idea what you are following up to, but
you had /\bre(?!:)(g(ular)?[\s-]*ex(p(res+ion)?)?)?s?\b/i in the
subject so my newsreader thought I would be interested.
> The problem of accessing a file outside of the cgi-bin directory may be due to
> the following : most httpd daemons, when executing a cgi-bin script, do this
> by means of a "restricted" shell (rsh, rksh,..). This limits what the script
> can do (such as changing the path or executing commands starting with a "/",
> see man pages of sh or rksh). Maybe this problem is of the same origin ?
> You can get around the limitation by calling a "real" script with an
> unrestricted shell from within a "placeholder" cgi-bin script.
This sounds nothing like a perl problem. Did you mean to post this
to a CGI group such as comp.infosystems.www.authoring.cgi? Or maybe
a web server group?
Elijah
------
actually uses a lot of smaller REs in the killfile
------------------------------
Date: 19 Dec 1997 20:25:37 GMT
From: "Don" <dgoyette@NoMoreSPAMpcisys.net>
Subject: Scanning the access_log file
Message-Id: <01bd0cbc$237fb980$9a664ccf@586win95>
Hello,
Just came across this list and hope someone can help me out...
Like many newbies here, I'm new to CGI/PERL _and_ Unix (but have lots of
programming experience on other platforms in other languages). I would
like to scan the access_log file and perform a "file access count" for all
files accessed from all web pages on our site, in the fastest (server time
wise) way possible. Our site is on an ISP's server and yes, we can run CGI
and the server has SSI available. Based on the current size of the ISP's
access_log file, I would guestimate that it's monthly size grows to about
400-600 MB. They usually purge it on a monthly basis.
Being unfamiliar with CGI/PERL and Unix (though I have some good books and
have created simple forms, e-mail reply and HTML response stuff), but
familiar with other languages, I guess I would need the following
'routines' and/or 'code sections':
1. A means to scan (read through) every record in the access_log file.
2. A means to select ONLY those records that contain the string
"~dgoyette".
3. A means to store all 'selected' records, or just the URL part of the
record (could be tens of thousands of records selected).
4. A means to scan all selected records accumulating totals for each
'specific' filename (for example "~dgoyette/index.html/whitesat.jpg").
5. A means to store the filenames and their accumulated totals in a
plain text file for transfer to our PC for printing and/or storage.
So, if one of you CGI/PERL/Unix gurus could point me in the right
direction, as to the proper PERL/Unix commands to research for each of
these purposes, I would be most grateful. The books we have include "teach
yourself CGI Programming with PERL 5 in a week", "Web Programming" and
"Unix in a Nutshell", so if you have specific chapter or page references,
that would help even more.
Thank you all, and Merry Christmas!
-Don
NOTE: If replying to me privately, please reply to:
(dgoyette"at-sign"pcisys.net) and NOT the auto-reply address.
------------------------------
Date: 19 Dec 1997 20:15:51 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Sending a signal to a process owned by someone else
Message-Id: <eli$9712191459@qz.little-neck.ny.us>
Keywords: sponsored by the letters R, T, F, and M
In article <349a535c.0@lightning.ica.net>, <lee.gammell@feedME> wrote:
> You can only do this if you make your script suid (setuid) to root
>
> chmod ug+xs script-name # sets suid and sgid
> chown root script-name
> chgrp mygrp script-name
This is not perl specific. (I bet that when you chown/chgrp anything
your suid and sgid bits get cleared anyway.)
> suid scripts will run in taint mode, thus you may need to untaint some variables
You should also check that they are reasonable.
> eg.
>
> $ENV{'PATH'} = '/bin:/usr/bin';
> $ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne '';
> delete @ENV{'IFS','CDPATH'};
>
> #To untaint and arg, eg. PID try
> if ($opt_pid =~ /(\d[1,5]$)/) {
> $opt_pid = $1; # process id is now untainted.
> }
Hmmm. Wonder if I can run ps and find all sorts of fun programs to
start signaling.
> # if you need the uid to be root as well as the euid (effective uid) include
>
> $< = $>; # that's doller followed by less-than (some software display is as $lt )
> kill 16, $opt_pid
What does init do on a SIGUSR1? Isn't the default action exit? Does
inetd know to trap that? I bet whatever shells people use on that
box don't. Wouldn't that be fun? Wait until someone (eg root) logs
in and then kill that shell immediately!
Maybe you want to find some more secure way to communicate with
your process.
Elijah
------
suid to root is very very undesirable
------------------------------
Date: 19 Dec 1997 12:42:38 -0800
From: Terrence Brannon <brannon@surf.usc.edu>
Subject: Statistics::Descriptive yields error in AUTOLOAD
Message-Id: <lbbtydkqtd.fsf@surf.usc.edu>
I run my module which is depedent on Statistics::Descriptive from the
perl debugger. After a lengthy execution, I get the following error:
--------------------------------------------------
gmax: 0.000500000000 P: 0.900000 S: 1.000000 mean vm: -35.9051604891666
sdev vm: 2.27927170326684
--------------------------------------------------
gmax: 0.000500000000 P: 1.000000 S: 0.000000 mean vm: -36.5760139142498
sdev vm: 1.53117282584733
--------------------------------------------------
gmax: 0.000500000000 P: 1.000000 S: 0.100000 mean vm: -36.9623043427503
sdev vm: 1.73932305375668
Carp::shortmess(/usr/lib/perl5/Carp.pm:68):
68:
100 levels deep in subroutine calls!
DB<<5>> T
@ = Carp::shortmess('Can\'t access `DESTROY\' field in class Statistics::Descriptive::Sparse') called from file `/usr/lib/perl5/Carp.pm' line 107
$ = Carp::croak('Can\'t access `DESTROY\' field in class Statistics::Descriptive::Sparse') called from file `/usr/local/lib/site_perl/Statistics/Descriptive.pm' line 86
$ = Statistics::Descriptive::Sparse::AUTOLOAD('Statistics::Descriptive::Sparse=HASH(0xb5ee83c)') called from file `/newport/freeway/brannon/scripts/perl//Persync.pm' line 1327
$ = eval {...} called from file `/newport/freeway/brannon/scripts/perl//Persync.pm' line 1327
$ = Persync::stat_gmax(0.000500000000) called from file `/newport/freeway/brannon/scripts/perl//Persync.pm' line 1309
$ = Persync::plot_wanted_gzipped_12_6 called from file `/usr/lib/perl5/File/Find.pm' line 212
$ = File::Find::finddepthdir('CODE(0x836d5c4)', './gmax_GLU=4.000000e-04/P=0.000000,S=0.000000', 2) called from file `/usr/lib/perl5/File/Find.pm' line 235
$ = File::Find::finddepthdir('CODE(0x836d5c4)', './gmax_GLU=4.000000e-04', 42) called from file `/usr/lib/perl5/File/Find.pm' line 235
$ = File::Find::finddepthdir('CODE(0x836d5c4)', ., 8) called from file `/usr/lib/perl5/File/Find.pm' line 176
$ = File::Find::finddepth('CODE(0x836d5c4)', .) called from file `/newport/freeway/brannon/scripts/perl//Persync.pm' line 1393
@ = Persync::traverse_plot_gzipped_12_6 called from file `(eval 18)' line 2
@ = eval '($@, $!, $,, $/, $\, $^W) = @saved;package main; $^D = $^D | $DB::db_stop;
&$Persync::traverse_plot_gzipped;' called from file `/usr/lib/perl5/perl5db.pl' line 926
$ = DB::eval called from file `/usr/lib/perl5/perl5db.pl' line 848
@ = DB::DB called from -e line 1
DB<<5>>
In my source code, the lines around line 1327 are:
sub stat_gmax {
print "stat_gmax", $/;
my ($P,$S,$g,@tmp,$stat);
$g=$Persync::traversing_gmax;
for $P (sort bynumber keys %{ $Persync::vmary{$g}}) {
for $S ( sort bynumber keys %{ $Persync::vmary{$g}{$P} } ) {
$stat = Statistics::Descriptive::Sparse->new(); # <--- line 1327
$stat->add_data( @{$Persync::vmary{$g}{$P}{$S}} );
$Persync::mean_vm{$g}{$P}{$S} = $stat->mean();
$Persync::sdev_vm{$g}{$P}{$S} = $stat->standard_deviation();
print "--------------------------------------------------", $/;
print "gmax: $g ";
print "P: $P ";
print "S: $S ";
print "mean vm: $Persync::mean_vm{$g}{$P}{$S}", $/;
print "sdev vm: $Persync::sdev_vm{$g}{$P}{$S}", $/;
}
}
}
Lines around line 86 in Descriptive.pm are:
sub AUTOLOAD {
my $self = shift;
my $type = ref($self)
or croak "$self is not an object";
my $name = $AUTOLOAD;
$name =~ s/.*://; ##Strip fully qualified-package portion
unless (exists $self->{'_permitted'}->{$name} ) {
croak "Can't access `$name' field in class $type"; # <-- line 86
}
##Read only method
return $self->{$name};
}
I would appreciate any help in getting this code working.
--
Terrence Brannon * brannon@lnc.usc.edu * http://quake.usc.edu/~brannon
USC, HNB, 3614 Way, Los Angeles, CA 90089-2520 * (213) 740-3397
------------------------------
Date: Fri, 19 Dec 1997 17:51:02 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Whats wrong with this simple code?
Message-Id: <ELG6x2.Fxy@world.std.com>
comdog@computerdog.com (brian d foy) writes:
>perhaps you wanted something simple like:
> #!/usr/bin/perl
> while( $line = <> )
> {
> print $line;
> }
> __END__
Except if the last line of the file ends in a "0" not followed by a
newline.
--
Andrew Langmead
------------------------------
Date: 19 Dec 1997 13:07:23 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Whats wrong with this simple code?
Message-Id: <67ed4r$6di$1@stok.co.uk>
Keywords: from just another new york perl hacker
In article <comdog-ya02408000R1912971210530001@news.panix.com>,
brian d foy <comdog@computerdog.com> wrote:
>In article <6E3540C5A6C3D9BD.424E32A0B9D8958A.A9EFCE3E27DA4B40@library-proxy.airnews.net>, Derek Balling <dballing@speedchoice.com> wrote:
>but why be THAT complicated?
>
> perl -e 'while(<>){print}' < infile
perl -pe '' infile
maybe?
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Fri, 19 Dec 1997 13:41:00 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Whats wrong with this simple code?
Message-Id: <comdog-ya02408000R1912971341000001@news.panix.com>
Keywords: from just another new york perl hacker
In article <ELG6x2.Fxy@world.std.com>, aml@world.std.com (Andrew M. Langmead) wrote:
>comdog@computerdog.com (brian d foy) writes:
>
>>perhaps you wanted something simple like:
>
>> #!/usr/bin/perl
>
>> while( $line = <> )
>> {
>> print $line;
>> }
>
>> __END__
>
>Except if the last line of the file ends in a "0" not followed by a
>newline.
oy. this sort of thing even generates a warning if one isn't stupid
enough to not use -w.
Value of <HANDLE> construct can be "0";
test with defined() at test.pl line 65535.
the correct way to do this is to test for a defined value:
while( defined($line = <>) )
{
print $line;
}
witness:
dog[36] cat test.pl
#!/usr/bin/perl -w
while( defined($line = <>) )
{
print $line;
}
__END__
dog[37] od -c test.txt
0000000 o n e \n t w o \n t h r e e \n 0
0000020
dog[38] perl test.pl < test.txt
one
two
three
0dog[39]
--
brian d foy <comdog@computerdog.com>
Meta Meta FAQ <URL:http://computerdog.com/Meta_MetaFAQ.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 19 Dec 1997 19:25:00 GMT
From: "Robert Garskof" <robert.garskof@snet.com>
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <01bd0cb3$21dcf510$d3a26d97@rgarskof>
Keep your options open, go for both!
--
/**************************************************************\
* Robert Garskof | robert.garskof@snet.com *
* ICAS Development Team | rgarskof@cris.com *
* Southern New England Telephone | *
\**************************************************************/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1510
**************************************