[8943] in Perl-Users-Digest
Perl-Users Digest, Issue: 2560 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 11 21:09:43 1998
Date: Mon, 11 May 98 18:00:35 -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 Mon, 11 May 1998 Volume: 8 Number: 2560
Today's topics:
Re: A regex teaser that ALMOST works! (Martien Verbruggen)
Basic MacPERL <mkgagne@earthlink.net>
Re: Basic MacPERL <rootbeer@teleport.com>
Re: Basic MacPERL (Kelly Hirano)
deleting first two lines of text file??? <andrew@iaccess.com.au>
Re: Detect if a script is already running? (Martien Verbruggen)
Re: Does Perl have a IDE?I don't like command line. (Ilya Zakharevich)
Re: Does Perl have a IDE?I don't like command line. <merlyn@stonehenge.com>
Re: Does Perl have a IDE?I don't like command line. (Ken Williams)
Re: Does Perl have a IDE?I don't like command line. <ljz@asfast.com>
Re: flock is not (Martien Verbruggen)
Re: FOR FUTURE REF(WHAT DOES THIS DO?) (Martien Verbruggen)
Re: good and bad newsreaders (was: Re: QRe: == vs. eq) (John Moreno)
Re: Help! Perl for Win32 Build 316 socket 'connect' que (Martien Verbruggen)
Re: how to create name for temporary file (Martien Verbruggen)
Re: In need of some code (Martien Verbruggen)
Re: Perl problem (TomH)
Re: Perl Win NT (Martien Verbruggen)
probs with OLE objects in PERL <jhedy@racingschools.com>
Reading Code Versus Writing Code, How You learn, was [R <birgitt@order.booktraders.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 May 1998 23:48:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: A regex teaser that ALMOST works!
Message-Id: <6j82nk$rv0$3@comdyn.comdyn.com.au>
In article <6j712l$iae$3@info.uah.edu>,
gbacon@cs.uah.edu (Greg Bacon) writes:
> I said efficient. I can step down a string with substr() all day long,
> but that's not very efficient. I can split out each character from a
> scalar to an array, but that's not very efficient for large scalars. I
> could play unpack() games, but I suspect even that would be expensive
> for large scalars.
>
> I reiterate: I wish Perl had an analogue to C's pointers to char.
Hmm.. perl is of course, not c. But, perl provides an interface to C,
called XS. it is probably possible to write a c function that can be
interfaced through an XS sub, etc. of course, it would still be less
efficient than real pointer operations, but that's a price one pays
for abstraction.
I even wonder if it would be more efficient than using substr.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: Mon, 11 May 1998 16:17:23 -0700
From: Michael Gagne <mkgagne@earthlink.net>
Subject: Basic MacPERL
Message-Id: <35578703.216B@earthlink.net>
I'm having trouble opening a file with MacPERL. I'm trying:
open($ACCESS_LOG, "Tigger:Documents:Access-LOG.com")
It doesn't seem to recognize the file. Please help with this most
simple (yet frustrating) problem. I don't have a problem opening a file
in a UNIX PERL.
Thanks,
Michael
------------------------------
Date: Mon, 11 May 1998 23:52:11 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Gagne <mkgagne@earthlink.net>
Subject: Re: Basic MacPERL
Message-Id: <Pine.GSO.3.96.980511165017.21974e-100000@user2.teleport.com>
On Mon, 11 May 1998, Michael Gagne wrote:
> I'm having trouble opening a file with MacPERL. I'm trying:
> open($ACCESS_LOG, "Tigger:Documents:Access-LOG.com")
(You mean, I hope, that $ACCESS_LOG is a filehandle. Or maybe your
real code doesn't have the dollar sign?)
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Generally, your diagnostic message should include the magical $! variable.
Does that tell you anything useful? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 11 May 1998 16:38:01 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: Basic MacPERL
Message-Id: <6j824p$2sd@Xenon.Stanford.EDU>
In article <35578703.216B@earthlink.net>,
Michael Gagne <mkgagne@earthlink.net> wrote:
>I'm having trouble opening a file with MacPERL. I'm trying:
>open($ACCESS_LOG, "Tigger:Documents:Access-LOG.com")
>
>It doesn't seem to recognize the file. Please help with this most
>simple (yet frustrating) problem. I don't have a problem opening a file
>in a UNIX PERL.
i can't remember, but do you need a leading : in your path, just like a
leading / in unix to specify an absolute path?
--
Kelly William Hirano Stanford Athletics:
hirano@cs.stanford.edu http://www.gostanford.com/
hirano@alumni.stanford.org (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20
------------------------------
Date: Tue, 12 May 1998 10:34:18 +1000
From: "Andrew Specht" <andrew@iaccess.com.au>
Subject: deleting first two lines of text file???
Message-Id: <6j858l$rno@sleipnir.iaccess.com.au>
hi,
HOw would i delete the first two lines of a text file using perl?
the chop command doesn't work..
any ideas?
Thanks :)
Andrew Specht
System Administrator
Internet Access Australia
andrew@iaccess.com.au
------------------------------
Date: 12 May 1998 00:03:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Detect if a script is already running?
Message-Id: <6j83ki$s1h$2@comdyn.comdyn.com.au>
In article <35572A79.576CD809@aloud.com>,
"Aloud.com" <alex@aloud.com> writes:
> Hi,
>
> Is there anyway to detect whether a perl script is already running?
A good way is to write a file with a pid somewhere. When a second
script starts, it checks the file, and can check if that pid is still
active. If not, it can safely proceed. You could also use some file
locking on some file somewhere.
This has the advantage above the 'ps' approach that it will work
everywhere. It's a method that is used by many many applications.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd. | inexactitude.
NSW, Australia |
------------------------------
Date: 11 May 1998 23:14:31 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6j80on$lnt$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Greg Bacon
<gbacon@cs.uah.edu>],
who wrote in article <6j7iuk$q68$5@info.uah.edu>:
> Please give us three good reasons why we should stroke even one key to
> help people who refuse to use man, perldoc, or grep? Perl requires at
> least that much of a clue.
Negative. Perl requires these abominations only on systems which do
not have a clue what a good documentation is. Witness Perl-OS/2's
distribution.
Ilya
------------------------------
Date: Tue, 12 May 1998 00:14:32 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <8csomg9whr.fsf@gadget.cscaper.com>
>>>>> "Ken" == Ken Williams <ken@forum.swarthmore.edu> writes:
Ken> The point is that beginners often lack some basic concepts that never
Ken> would have occurred to the people that wrote the man pages. Check out the
Ken> beginning of the LLama book, it has a quote by Randal (I think) saying
Ken> something like "I didn't learn English by reading the dictionary, and
Ken> likewise I didn't learn to program by reading books and man pages." Or
Ken> something like that.
That's not the llama book... that's in the preface I wrote to
"Effective Perl Programming", full text available online at
http://www.effectiveperl.com/preface.html
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 112 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 11 May 1998 20:26:09 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <ken-1105982026090001@news.swarthmore.edu>
In article <8csomg9whr.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:
>>>>>> "Ken" == Ken Williams <ken@forum.swarthmore.edu> writes:
>
>Ken> The point is that beginners often lack some basic concepts that never
>Ken> would have occurred to the people that wrote the man pages. Check out the
>Ken> beginning of the LLama book, it has a quote by Randal (I think) saying
>Ken> something like "I didn't learn English by reading the dictionary, and
>Ken> likewise I didn't learn to program by reading books and man pages." Or
>Ken> something like that.
>
>That's not the llama book... that's in the preface I wrote to
>"Effective Perl Programming", full text available online at
>
> http://www.effectiveperl.com/preface.html
Oops... sorry, my mistake. I actually bought those two books together
last week. An unlikely combination, I know... =)
------------------------------
Date: 11 May 1998 20:50:06 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <ltemy048jl.fsf@asfast.com>
gbacon@cs.uah.edu (Greg Bacon) writes:
> In article <6j7brt$6g6@mozo.cc.purdue.edu>,
> gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
> : In spite of the slew on non-answers to this question, I
> : don't think that a good IDE (written, of course, in perl
> : using Tk) would be such a bad thing. Especially
> : considering that most people know how to pull down the
> : "help" menu. Certainly more than know how to use
> : perldoc.
>
> Please give us three good reasons why we should stroke even one key to
> help people who refuse to use man, perldoc, or grep? Perl requires at
> least that much of a clue.
I cannot come up with three reasons why *you* or anyone else should do
this. I respect your choices in what you want to do or not do.
However, here is why *I* do this:
(1) I think that Perl is a wonderful language and it pleases me
to see lots of people using it.
(2) I love helping people when I have time.
(3) I have given this kind of technical help to people for over
20 years and I have never had even one of these people become
dependent on my help or to develop some sort of "the world
owes me a living" attitude. On the contrary, to the best of
my knowledge, 100 percent of the people who have received
help from me would have been ashamed to have to be dependent
on others for learning and are proud of what they have been
able to learn on their own.
As for why I am not categorically opposed to a Perl IDE:
(1) I truly believe that most people who would want to use an
IDE would not use it instead of man, perldoc, or grep, but
rather, in conjunction with these tools.
(2) Even though I personally do not generally use IDE's, I know
a lot of people who are more productive using such things
to help develop code.
(3) It is quite possible for a person to use an IDE and still learn
the language in question to the same level of proficience and
compentency as those people who shun IDE's.
> Perl would cease to be the language we know and love if we watered it
> down to meet the needs of the least common denominator. An army of Ken
> Thompsons couldn't fully idiot-proof even the simplest program.
The language need not change one iota simply due to someone's choice
of writing an IDE. IDE's did not water down C++. IDE's did not water
down Smalltalk. IDE's did not water down APL. IDE's did not water
down Java.
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: 12 May 1998 00:00:05 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: flock is not
Message-Id: <6j83e5$s1h$1@comdyn.comdyn.com.au>
In article <Pine.GSO.3.95.980508135725.29060B-100000@cp.pathfinder.com>,
"Andrew F. Lee" <andrewf@cp.pathfinder.com> writes:
> perl -v gives me
>
> This is perl, version 5.002
You should upgrade.
> The following script dies :
>
> #!/usr/local/bin/perl
You should use -w
> open(DATA, $file) or die $!;
DATA is a special file handle in perl. You should use another name.
# perldoc perldata
> flock(DATA, $LOCK_EX) or die $!;
You can't get an exclusive lock on a file that you didn't open for write.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: 11 May 1998 23:13:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: FOR FUTURE REF(WHAT DOES THIS DO?)
Message-Id: <6j80mv$rl0$3@comdyn.comdyn.com.au>
Please read the following information on how to choose a good subject
line:
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
In article <1998051101300200.VAA18528@ladder03.news.aol.com>,
j1t1w1@aol.com (J1T1W1) writes:
> All,
> Who answer my posting "WHAT DOES THIS DO?", I appreciate those of you who
See my comment above. It's rude to shout.
> answer my question right out, but those of you who have been programming in
> Perl for quite sometime need to remember that there are people out here that
> are trying to learn and that you shouldn't treat use like we are stupid.
> Because, I know you were in our shoes at one time, seeking help from the
> experts.
As a matter of fact: I wasn't. A lot of people weren't. They tried to
find out themselves. Only in cases where it really really got hard
would they turn to the newsgroup, not really the 'experts' themselves.
It's not the wanting to learn that we object to. It's the
gimme-gimme-gimme attitude. It's the 'Answer my question, because I'm
to lazy to do any investigation myself' attitude. It's the "I can't be
bothered to read FAQs or Usenet netiquette documentation" attitude
that turns people off.
> J1T1W1
Using a handle like this is also not something that is looked
favourably on by the people who have been on the Internet for more
than a fortnight. it brings up nasty associations.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: Tue, 12 May 1998 00:44:09 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: good and bad newsreaders (was: Re: QRe: == vs. eq)
Message-Id: <1d8vewb.qxkccjvokdueN@roxboro0-002.dyn.interpath.net>
In news.software.readers Greg Bacon <gbacon@cs.uah.edu> wrote:
> phenix@interpath.com (John Moreno) writes:
>
> : It is my opinion they didn't include the X-Newsreader header because
> : they didn't want people to know what program (Ameol2) was producing such
> : junk. I of course don't have any evidence to base this on except for
> : the lousy articles that it produced.
>
> Here's what Henry has to say on the matter (from Son-of-1036, Section
> 4.2.2, ``Undesirable Headers''):
>
-snip-
> NOTE: Information that someone, somewhere, might
> someday find useful is best omitted from headers.
> (There's quite enough of it in article bodies.)
> Headers should contain information of known util-
> ity only. This is not meant to preclude inclusion
> of information primarily meant for news-software
> debugging, but such information should be included
> only if there is real reason, preferably based on
> experience, to suspect that it may be genuinely
> useful. Articles passing through gateways are the
> only obvious case where inclusion of debugging
> information appears clearly legitimate. (See sec-
> tion 10.1.)
Given the wide swing in what a newsreader can do, then I think this is
of more general use than Organization, Path, most of the stuff in
References and NNTP-Posting-Host. This isn't the clmperl isn't the
first newsgroup to have discussions about people posting badly formatted
articles, and I doubt if it'll be the last. Knowing what newsreader
people are using IS useful on a day to day basis (not for everybody
every day, but somebody every day) and I think it should be included by
default. Hell, this thread started when Tom said he was filtering based
upon newsreaders.
> NOTE: A useful rule of thumb for software imple-
> mentors is: "if I had to pay a dollar a day for
> the transmission of this header, would I still
> think it worthwhile?".
Do I get the rest of it for free? Then I'd be willing to pay 83".
--
John Moreno
------------------------------
Date: 11 May 1998 23:41:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help! Perl for Win32 Build 316 socket 'connect' question
Message-Id: <6j82av$rv0$1@comdyn.comdyn.com.au>
In article <01bd7ca7$02a6a420$b5c02e87@outpost2.ciin.att.com>,
"Andy" <ngai@att.com> writes:
> Hi,
> I've tried the following piece of code to connect an NT 4.0 client running
> Perl for Win32 Build 316 to an NT-based web server and it fails to
> establish a connection to the server. I've tried the same code on HP-UX
> running Perl 5.003 and it works fine. I've isolated the problem to the
> 'connect' call and would like to know if anyone had come across a similar
> problem with the 'connect' function and have a solution to this problem.
> Did I overlook something or failed to install a required module?
You probably need to have a look at the Socket module, which is a bit
more reliable way of using sockets (comes with perl). The code you
provided won't work on my platform (Solaris 2.6) (fails on socket).
You should also use the -w flag with perl, to get a few more warnings.
There is an example in the perlipc documentation that works well.
# perldoc perlipc
# perldoc Socket
If all you need to do is connect to a web server, and retrieve some
pages, you might be better off using the LWP package, and not worry
about the low level socket operations. Of course, if you like playing
with sockets, I'd advise you to read the above mentioned
documentation.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd. | network - Mitchell Kapor
NSW, Australia |
------------------------------
Date: 11 May 1998 22:49:26 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: how to create name for temporary file
Message-Id: <6j7v9m$rl0$1@comdyn.comdyn.com.au>
In article <35532DF5.BEF2F206@matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> writes:
> Why bother? A file is as temporary as you want it to be!
>
> Just create a file (I would call it MYFILE.TEMP or whatever),
What if you have 40 concurrent processes trying to access that file?
This might, for example, be the case if the processes are CGI
programs.
You really need to be more careful with temporary file names. One day
it will bite you, if you aren't, and just assume things.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: 12 May 1998 00:22:56 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: In need of some code
Message-Id: <6j84p0$s4t$2@comdyn.comdyn.com.au>
In article <6j7f6f$69v$2@wiley.napanet.net>,
Steve_NoSpam@adnd.com writes:
>
> I Need a snipit of code that will parse a file and everywhere it finds
> a web address in the text it will tack before it
>
> <a href=thewebaddresshere> and tack after it </a>
Go to www.dejanews.com, and search for:
~g comp.lang.perl.misc & regexp & href
The threads that come up there have a bit of discussion for you about
what the problems might be, and pointers to possible solutions, and
even one ready-made one.
> (note to reply via e-mail remove the _NoSpam from my address)
My editor is broken. I can't edit email addresses. Bummer.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Mon, 11 May 1998 18:51:43 GMT
From: beans@bedford.net (TomH)
Subject: Re: Perl problem
Message-Id: <355745f8.34594054@news.bedford.net>
This looks suspiciously like a homework assignment, given in hope that
the students would be forced to root around in the documentation until
they found the answer and stumbled across lots of other good things in
the process. Here's the answer; why/how this works is clearly
explained in perlfunc.
##########################
$\ = "\n";
$a = 1;
$function = "+";
$b = 2;
$c = 4;
$ans = eval "$a $function $b $function $c ";
print $ans;
#################################
On Mon, 11 May 1998 14:04:57 +0100 (BST), CBS5AHR@leeds.ac.uk (A.H.
Roberts) wrote:
>I have just recently started to learn Perl, and have come across a problem
>with something I am trying to do.
>
>Basically I wrote a program to take 3 numbers to <STDIN> ($a, $b and $c),
>then have a symbol typed in and called $function - the sybmol being
>+, -, * or /.
>...
>What I am TRYING to do is have $function do this:
>
>$ans = $a $function $b $function $c
>
>and give an answer depending on which operator $function was.
>
>However, as it records $function as a string not an operator it don't work.
>
>IS there a way of doing this?
------------------------------
Date: 11 May 1998 23:01:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Win NT
Message-Id: <6j800c$rl0$2@comdyn.comdyn.com.au>
<OFFTOPIC>
In article <35572ebb.254920696@news>,
sdinitto@kronos.com (Scott DiNitto) writes:
> On 5 May 1998 11:44:34 GMT, scott@softbase.com wrote:
>
>>The first thing is you can't execute a CGI program from a browser. If
>>you mean, "when I view the results of the CGI executing on the server
>>with my browser", then say that. If not, then that's one of your
>>problems. People reading your vague post have no idea which.
>
> Okay, yes you can. When querying an executable file from a browser,
> the instruction to execute does come from the browser interface. The
> execution takes place on the server.
The instruction to execute does not come from the browser at all. The
browser has no clue when it goes off and requests a URI from a server
what it is going to get back or what sort of content delivery is going
to take place.
How is a browser supposed to know to 'instruct' the server to
'execute' and 'executable'? How is the browser supposed to know wether
something is an 'executable'?
A web server is free to do whatever it wants. All it needs to do is
accept a bunch of requests as described in RFC 1945, and return
responses as described in the same RFC. How it generates those
responses is a totally different issue, and depends on the server.
The CGI specification is another story, and has still nothing to do
with the browser. It specifies which things a server must provide to
a program, according to this interface. That's it.
Maybe you should read up on a few documents before making statements
like that.
</OFFTOPIC>
>>Likely, you haven't installed the ISAPI DLL version of Perl. You
>
> Don't be so confident this is the problem. I do not run the DLL, but I
> have run into the same problem with some scripts WHERE AS some others
> run just fine without it.
Then most likely, those scripts don't use that same package. You
probably have some package that is needed installed in the wrong
place.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Mon, 11 May 1998 16:42:00 -0700
From: "John Hedy" <jhedy@racingschools.com>
Subject: probs with OLE objects in PERL
Message-Id: <894930202.644097@slave1.aa.net>
I wrote a simple PERL script using your example and tried to run it
from IIS 4. However, the script just hangs and never returns control back
to the browser. When I single step thru the script with a PERL debugger,
it looks like the component calls are working as expected and the
scripts completes successfully with the expected results. The strange
part is if I use _step_ the script works, if I use _next_ or _continue_
after a certain point, the script hangs as in the browser. I don't see
why. Can anyone help? I had PERL for Win32 build 315 with CGI.pm and
ODBC.pm installed. Didn't work with that although I had read a
comment saying that Perl 316 might have addressed memory leak problems with
the OLE component. I downloaded and installed PERL for Win32 build 316 .
Same results.
I am attaching my code below. Any assistance you can provide would be
much appreciated. Thanks in advance!
#!/usr/bin/perl -- -*-perl-*-
# testauth.pl
use CGI qw(:all);
use OLE;
print header;
print start_html(-BGCOLOR=>'#FFFFFF');
print "SCRIPT_NAME is $ENV{SCRIPT_NAME}<BR>";
print "Server_Name is $ENV{SERVER_NAME} <BR>";
print "HTTP_AUTHORIZATION is $ENV{HTTP_AUTHORIZATION}<BR>";
$user = getUser();
print "user is $user <BR>";
print end_html;
exit;
sub getUser {
$authx = CreateObject OLE "AUTHXOCX.AuthXOCXCtrl.1";
$userid = $authx->CurrentUserName($ENV{SERVER_NAME},
$ENV{SCRIPT_NAME}, $ENV{HTTP_AUTHORIZATION});
undef $authx;
return ($userid);
}
I've been able to successfully write an ASP script that calls the OCX
component successfully. If nobody can determine what is wrong above, does
anyone have an example of a PERL script calling an ASP that then returns
control and parameters back to the PERL script?
Something else of interest to note:
I added a couple more statements in my script -
$authx->DESTROY;
OLE->DESTROY;
(where $authx was the object I created using CreateObject OLE...) . Now,
in the debugger I _sometimes_ see an error:
"Attempt to free unreferenced scalar during global destruction.
OLE::DESTROY called at testauth.pl line 0
eval {...} called at testauth.pl line 0"
I noticed that even after I had explicitly called OLE->DESTROY and
$authx->DESTROY, the process tried to call the OLE->DESTROY function
immediately after the exit 0; in my script. So it seems like a clean up
process is _always_ initiated at the end of execution anytime an OLE object
is created. Because my script had already completed that by calling it
explicitly from the program, the process could not find anything to
"destroy" . The question is, why was the script then hanging when I hadn't
called the OLE->DESTROY from my program? It does look like a memory problem
to me.
Can anyone help? Assistance is much appreciated.
------------------------------
Date: Mon, 11 May 1998 19:43:54 -0400
From: Birgitt Funk <birgitt@order.booktraders.com>
Subject: Reading Code Versus Writing Code, How You learn, was [Re: perl scripts dealing with /etc/passwd]
Message-Id: <35578D3A.17FB98E7@order.booktraders.com>
[last four posts in this thread]
Allan M. Due <due@murray.fordham.edu> wrote:
: Your argument for the use of modules is well made. On the other hand
I
: think it is also important to understand how code is correctly written
in
: order to make informed decisions about the use of modules. Otherwise
you
: obtain the circumstance that others in this newsgroup are complaining
about
: currently. That users become consumers and not programmers. Modules
are a
: double edged sword in that sense. They have the potential to
encourage
: people to blindly use tools without understanding them, and without
learning
: how to code correctly in the first place. Just trying to get it right
at
: the beginning so I don't have to go back and unlearn bad habits.
Eric Bohlman <ebohlman@netcom.com> wrote:
: Hmm. All the Perl modules that I've seen over on CPAN come in source
: form. That means that if a module has a good reputation, you can
: actually *read* it to see what correctly-written code looks like. 28
: years ago, Gerald Weinberg argued in _The Psychology of Computer
: Programming_ that reading good code was a very effective, but
strangely
: underrated, way to improve one's own programming skills. More
recently,
: Donald Knuth has talked about "literate programming."
: Your arguments would make perfect sense if you were talking about C++
: programmers using canned commercial binary-only libraries. But that
: isn't the case with Perl programming.
"Allan M. Due" <due@murray.fordham.edu> wrote:
: I agree with your points completely, one of the things I like about
Perl is
: the code is always there for you to see. My point is this. Folks
often
: post questions asking how do I do X, Then the suggestion is made that
a
: module already does X, in a better way, so go use that module. A
subtle
: danger is that some will interpret such comments to mean that it is
not
: important to understand the problem, just let the module take care of
it as
: it solves all potential problems. The modules become a black box.
They did
: not understand the problem in the first place, but now they have a
solution,
: so they never bother to understand the programming issues, and they
become
: blind consumers. Now this would be short sighted of the person using
the
: module but it is an issue. Which leads to the problem being discussed
: elsewhere which is that module users start to say things like such and
such
: module doesn't work, fix it for me, rather than looking at the code
that is
: available. Now this is not a major issue but I think it does
encourage some
: folks to not try and solve problems on their own.
Tom Phoenix wrote:
> It's not hard to fix this code to follow the specs, but why bother? There
> are good modules out there, ones which are easy to use, ones which do this
> for you by using code that's been debugged for your convenience.
>
> As my pal Randal says, "Don't try to re-invent the wheel; sometimes you
> end up with casters." :-)
I apologize if this is a bit too far off the specific
discussion regarding using modules as mentioned in the
above posts, but I was asking myself since a while what the
right approach is to learn to program:
1. by writing code
(in the sense that you read about a topic,
you go through exercises given in books and then
you test yourself immediately in posting yourself
a problem, write a little program from the very
beginning on without having covered at least one third
of the material and knowing that all this must be the
worst code one can think of and most probably a dangerous
one too).
2. by reading code
(of which you know it is well written and tested code
and try to translate it as the main task in the beginning
and trying to write your own little programs at a much
later point).
I see the learning process similar to how a child learns to read
and write or how an adult learns a foreign language.
There are very distinct and heavily discussed and different approaches
on how to go from babytalk and 'babywrite' to become a proficient
reader and writer in your first and all following languages you learn.
I have my way of thinking about it, but like to hear if others
think there are analogies which could be drawn for learning a
programming language and what experienced programmers and teachers
of programming would think has more weight and effect to a beginning
learner.:
It is often said that if you don't know ANY programming language
it's different. Same thing if you can't read and write well the
first language in your life you can't read and write well any
foreign language you learn later on.
So if you think the approach should be different dependent on
knowing already one programming language versus none, I would
like to know too.
But the main question is what applies when learning the first
programming language.
Birgitt Funk
P.S. I admit this is a very general questions again, if someone
likes to respond, may be it would be better to email me.
I have no feeling for how this post will be judged as
appropriately being posted here. But your answers would interest
me a lot. Thanks for your time reading this.
------------------------------
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 2560
**************************************