[10707] in Perl-Users-Digest
Perl-Users Digest, Issue: 4307 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 27 07:07:24 1998
Date: Fri, 27 Nov 98 04:01:36 -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, 27 Nov 1998 Volume: 8 Number: 4307
Today's topics:
Re: Obfuscation of perl scripts birgitt@my-dejanews.com
Re: Perl parsing error jannuzzi@csn.com.br
Re: Perl Scripting Error <erikd@zip.com.au>
Re: Perl Scripting Error (Larry Rosler)
Re: Perl Scripting Error dave@mag-sol.com
Re: problem dave@mag-sol.com
read from a program ? <tim.schelfhout@telenet.be>
Re: read from a program ? <ebohlman@netcom.com>
Re: Stupid question: Script never terminates? (Ilya Zakharevich)
Re: Thanksgiving <bill@fccj.org>
trying to print ALL keys in symbol table <girishd@gsslco.co.in>
Re: Y2K and Programmer Denial (David Alan Black)
Re: Y2K and Programmer Denial <ajohnson@gatewest.net>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 27 Nov 1998 09:39:54 GMT
From: birgitt@my-dejanews.com
Subject: Re: Obfuscation of perl scripts
Message-Id: <73ls19$m3n$1@nnrp1.dejanews.com>
In article <ylvhk22mog.fsf@windlord.stanford.edu>,
Russ Allbery <rra@stanford.edu> wrote:
> Vlad Volkov <vvolkov@benton.com> writes:
>
> > If you sell consulting in Perl for some
> > particular field, in my case data loaders, you would not want somebody
> > on the client side to learn the technics and take the business from you,
> > eh?
>
You might be amazed how many of your clients just learn the techniques (of
course surely not from you) BECAUSE you seem to be so afraid to raise
your competition.
Most clients who made the decision to pay for a consultant have made
a decision NOT to learn the techniques, which doesn't mean they are
not CAPABLE of doing so and changing their mind.
If challenged enough they do learn what they need and/or look for better
code or consultants, who don't forget what they are there for.
:-)
Birgitt
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 27 Nov 1998 11:07:45 GMT
From: jannuzzi@csn.com.br
Subject: Re: Perl parsing error
Message-Id: <73m15q$qb3$1@nnrp1.dejanews.com>
In article <Pine.GSO.4.02A.9811261017360.23068-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
> > The error I got when I call the script URL is "Perl parsing errors".
>
> That's not an error message listed in the perldiag manpage. Could it be
> from an old version of Perl?
No... I4m running 5.004. But with your (and other informations) now I4m
thinking this error is due to a mistake in the Oracle Web Server
configuration. I4ll let you know when I find an answer.
> > When I comment the line "use LWP::UserAgent" the
> > script run Ok.
>
> Well, if that fixes things, why are you complaining? :-)
Hehe... That4s a nice point of view. ;-)
> Hope this helps!
Thanks for the tips!
Regards,
Alessandro L. Jannuzzi
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 27 Nov 1998 18:24:55 +1100
From: Erik de Castro Lopo <erikd@zip.com.au>
Subject: Re: Perl Scripting Error
Message-Id: <365E53C7.5D08F2A9@zip.com.au>
Freeness wrote:
>
> Can anyone point out anything wrong with the following script? I have had a
> 13-hour-long head ache from this... after I type perl -w gotoad.cgi in
> telnet it says "syntax error at gotoad.cgi line 15, near ")
>
> open"
> Execution of gotoad.cgi aborted due to compilation errors.
> --PLEASE HELP!
>
> #!/usr/local/bin/perl
> $input = $ENV{'QUERY_STRING'};
> @input = split(/&/, $input);
> foreach $subinput(@input) {
> ($name, $value) = split(/=/, $subinput);
> $name =~ tr/A-Z/a-z/;
> $value =~ tr/A-Z/a-z/;
> $name = $value;
> }
> $account =~ tr/a-z/A-Z/;
> open(DISPLAY, "accounts/$account.txt");
> @file = <DISPLAY>;
> close(DISPLAY)
Put as semilcolon after the previous statement.
> open(DKPC, ">accounts/$account.txt");
> foreach $line(@file) {
> ($advert, $hits) = split(/=/, $line);
> if ($advert eq $ad) {
> print DKPC "$advert=++$hits";
> }
> else {
> print DKPC "$advert=$hits";
> }
> }
>
> print "Content-type: text/html\n\n";
> print "The Ad: $ad for Account: $account was accounted for";
> exit;
Erik
--
+-------------------------------------------------+
Erik de Castro Lopo erikd@zip.com.au
+-------------------------------------------------+
#!/bin/sh
unzip ; strip; touch ; finger ; mount ; gasp ;
yes ; more ; umount ; sleep ;
------------------------------
Date: Fri, 27 Nov 1998 00:25:57 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Scripting Error
Message-Id: <MPG.10c801eb27b1b790989928@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <73lg3u$bln$1@birch.prod.itd.earthlink.net> on Fri, 27 Nov
1998 01:15:42 -0500, Freeness <Webmaster@Freeness.net> says...
> Can anyone point out anything wrong with the following script? I have had a
> 13-hour-long head ache from this... after I type perl -w gotoad.cgi in
> telnet it says "syntax error at gotoad.cgi line 15, near ")
>
> open"
> Execution of gotoad.cgi aborted due to compilation errors.
> --PLEASE HELP!
There's a whole lot more wrong besides the missing semicolon on line 13
that Erik de Castro Lopo has already pointed out. And I don't mean your
failure to use CGI.pm, which others may point out, but not me.
> #!/usr/local/bin/perl
You are missing the '-w' flag (though you tried to supply it from the
command line, which isn't nearly as good). You are also missing 'use
strict;' which would force you to declare variables and is an excellent
habit to develop.
> $input = $ENV{'QUERY_STRING'};
What happens if $ENV{QUERY_STRING} is undefined?
> @input = split(/&/, $input);
> foreach $subinput(@input) {
> ($name, $value) = split(/=/, $subinput);
> $name =~ tr/A-Z/a-z/;
> $value =~ tr/A-Z/a-z/;
> $name = $value;
Surely you cannot mean that. Each time through the loop, you process
$name, then overwrite it with $value, then never use it. Probably what
you intend is to use $name as a symbolic reference to a variable, in
which case you would write
$$name = $value;
But this is a very poor approach, and the following (using a hash to
store the arguments) is much better:
$args{$name} = $value;
> }
> $account =~ tr/a-z/A-Z/;
Nothing in the above code gives a value to $account.
> open(DISPLAY, "accounts/$account.txt");
Where is the test and report for failure to open the file? How do you
know what this path will be relative to when the program is run by the
web server? You usually need to use an absolute path.
> @file = <DISPLAY>;
> close(DISPLAY)
OK. So it's missing a semicolon. You should become aware that when a
compiler reports an error on line 15, say, it means that it became aware
of the error on that line. The actual error is usually on a previous
line, in this case line 13. The diagnostic you showed above pinpointed
it exactly.
>
> open(DKPC, ">accounts/$account.txt");
Where is the test and report for failure to open the file? How do you
know what this path will be relative to when the program is run by the
web server? You usually need to use an absolute path.
In any case, this seems to be the same file you just read. You might
consider opening it for update ("+<..."). There should be examples of
how to do this in the books you should be reading. (I hope one of the
is "Learning Perl")
> foreach $line(@file) {
> ($advert, $hits) = split(/=/, $line);
> if ($advert eq $ad) {
> print DKPC "$advert=++$hits";
Nothing in the above code gives a value to $ad.
> }
> else {
> print DKPC "$advert=$hits";
> }
> }
It appears that each of your $account.txt files has one and only one
line (and not even a complete one, because there is no newline). That
makes the two foreach loops rather misleading. Furthermore, the second
alternative above seems to write back exactly what was in the file. Is
this a good strategy?
> print "Content-type: text/html\n\n";
> print "The Ad: $ad for Account: $account was accounted for";
> exit;
Assuming $ad and $account get values somehow, this part seems correct.
Wihout CGI.pm! :-)
Good learning and good luck!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 27 Nov 1998 11:40:40 GMT
From: dave@mag-sol.com
Subject: Re: Perl Scripting Error
Message-Id: <73m33n$rpa$1@nnrp1.dejanews.com>
In article <73lg3u$bln$1@birch.prod.itd.earthlink.net>,
"Freeness" <Webmaster@Freeness.net> wrote:
> Can anyone point out anything wrong with the following script? I have had a
> 13-hour-long head ache from this... after I type perl -w gotoad.cgi in
> telnet it says "syntax error at gotoad.cgi line 15, near ")
> open"
> Execution of gotoad.cgi aborted due to compilation errors.
> --PLEASE HELP!
Did you look at line 15? Or at the lines around it? How about the one that
says 'close(DISPLAY)'? Anything obvious missing there? Like a semicolon...
Other things you should consider:
1/ -w and use strict. Will pick up most of your errors. 2/ Use CGI.pm. At
least to extract the values of the form parameter. 3/ Check the results from
open. 3/ I *think* that your parameter parsing is doing less than you think
it is. Do you think that $name = $value will create variable called $name and
set it to $value. Well it doesn't. It overwrites the value in $name every
time. 4/ This means that you are using many variables that are undefined
(e.g. $account, $ad and $hits).
hth,
Dave...
> #!/usr/local/bin/perl
> $input = $ENV{'QUERY_STRING'};
> @input = split(/&/, $input);
> foreach $subinput(@input) {
> ($name, $value) = split(/=/, $subinput);
> $name =~ tr/A-Z/a-z/;
> $value =~ tr/A-Z/a-z/;
> $name = $value;
> }
> $account =~ tr/a-z/A-Z/;
> open(DISPLAY, "accounts/$account.txt");
> @file = <DISPLAY>;
> close(DISPLAY)
>
> open(DKPC, ">accounts/$account.txt");
> foreach $line(@file) {
> ($advert, $hits) = split(/=/, $line);
> if ($advert eq $ad) {
> print DKPC "$advert=++$hits";
> }
> else {
> print DKPC "$advert=$hits";
> }
> }
>
> print "Content-type: text/html\n\n";
> print "The Ad: $ad for Account: $account was accounted for";
> exit;
--
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 27 Nov 1998 09:11:24 GMT
From: dave@mag-sol.com
Subject: Re: problem
Message-Id: <73lqbl$kpv$1@nnrp1.dejanews.com>
In article <73kddk$9pc$1@Masala.CC.UH.EDU>,
"Sean Mintz" <stmintz@yahoo.com> wrote:
> hello!
> in my program i tried to do this;
>
> foreach $dog ($log{$num}) {
> print "$dog\n";
> }
>
> if there is more than 1 thing in $log{$num} it only says the last one
There can only be one thing in $log{$num}, a hash can only contain scalars.
Perhaps if you showed use a cutdown version of the code that populates the
hash, we might be able to help a bit more.
Alternatively, perldoc perldata, perldoc perlref and perldoc perldsc may well
answer most of your questions.
hth,
Dave...
--
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 27 Nov 1998 08:45:03 GMT
From: "Tim Schelfhout" <tim.schelfhout@telenet.be>
Subject: read from a program ?
Message-Id: <01be19e1$f6d78cd0$4737000a@tl000143>
Me again,
I'm trying to write a perl script which reads output from a program and
then formats some of its data. So far I've come up with the following but
I don't seem to get any data
back from the program although I know it's connected to it.
($phone,$rest)=@ARGV;
$cli="/opt/cli/bin/cli";
open (CLI,"|$cli") || die "Can't connect to $cli\n";
print CLI,"searchdn $phone\n";
close (CLI);
This normally should print out something like:
"connected to Server : l1mech1 echo report cauline
MECH1,CCF-1,CCU-4,SA20001,CAU0022 { .... }"
I guess it's normal that I'm not getting anything back since I'm printing
to the pipe but don't get anything out of it. Is there any way
to do this in native perl rather than doing it with the 'system
(/opt/bin/cli .... )' solution ?
Thanks guys .. if anyone does find a solution
Timpie
------------------------------
Date: Fri, 27 Nov 1998 09:23:51 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: read from a program ?
Message-Id: <ebohlmanF32q3s.BsF@netcom.com>
[comp.lang.perl removed from followups as it was superseded long ago]
Tim Schelfhout <tim.schelfhout@telenet.be> wrote:
: I'm trying to write a perl script which reads output from a program and
: then formats some of its data. So far I've come up with the following but
: I don't seem to get any data
: back from the program although I know it's connected to it.
: ($phone,$rest)=@ARGV;
: $cli="/opt/cli/bin/cli";
: open (CLI,"|$cli") || die "Can't connect to $cli\n";
While this isn't the source of your problem, you should be aware that
this open() could successfully return *without* you being properly
connected to the pipe. In fact, the only reason it would fail would be
that your system was unable to fork a new process. If the fork
succeeded, but the exec of the external program failed, you wouldn't know
about it until later.
: print CLI,"searchdn $phone\n";
This *is* the source of your problem. If you specify a filehandle in a
print statement, you must *not* put a comma after the filehandle. The
comma confuses the compiler into thinking that you want to print two
items to STDOUT: the scalar value of CLI, and the quoted string.
: close (CLI);
This is where you need to check the return value to make sure the
external program executed properly.
------------------------------
Date: 27 Nov 1998 09:35:33 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Stupid question: Script never terminates?
Message-Id: <73lrp5$c6h$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Abe
<abe@abe.com>],
who wrote in article <qOr72.1678$eZ4.3614740@news4.atl>:
> Never mind. I feel so damn stupid now that I see what I did. Sub
> error_notfound called sub Header which called sub GetSpecs which called
> sub error_notfound, etc. There's the endless loop. Newbie mistake I
> guess. Yikes.
The only newbie mistake is that you did not run it under debugger,
which would advise you on this condition momentarily.
Ilya
------------------------------
Date: Thu, 26 Nov 1998 21:37:31 -0500
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Thanksgiving
Message-Id: <365e103e.0@usenet.fccj.cc.fl.us>
In article <73jitc$gt6$0@206.165.167.210> , "Allan M. Due"
<due@murray.fordham.edu> wrote:
>Hi Folks,
>
<snip>
> Well, I have rambled on more than I intended. Have a great holiday.
>
Happy belated Thanksgiving to you as well, Allen :]
-Sneex- :]
________________________________________________________________________
Bill Jones, Webmaster x3089 http://www.fccj.org/cgi/mail?webmaster
------------------------------
Date: Fri, 27 Nov 1998 15:48:21 +0530
From: "Girish Deodhar" <girishd@gsslco.co.in>
Subject: trying to print ALL keys in symbol table
Message-Id: <73lu4i$t12@uranus.m-netz.ch>
Hi,
i've just started learning perl.
in the following i am trying to pring ALL the keys in symbol table
those in %main:: and those in other package symbol tables contained in
main
however the inner loop (the one which has print "inside\n") never gets
executed
can someone tell me what is the mistake
~girish
sub addkeys {
my ($href,$parentname) = @_;
foreach $keyname (keys %$href) {
# print qq|$parentname\:\:$keyname\n|;
if(! $keyname =~ m|main|) {
print "inside\n";
push(@array_of_keys,qq|$parentname\:\:$keyname|);
&addkeys($$href{$keyname},qq|$parentname\:\:$keyname|) if $keyname =~
m|::$|;
}
}
}
&addkeys(\%main::,"main");
print join("\n",@array_of_keys)
------------------------------
Date: 27 Nov 1998 03:28:35 -0500
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Y2K and Programmer Denial
Message-Id: <73lnrj$5qb$1@pilot.njin.net>
finsol@ts.co.nz writes:
>Recent debate on this and other programming newsgroups, regarding Y2K issues,
>has prompted me to write on the subject of programmer denial. This article was
>recently published in NZ Computerworld.
>Many of you following the debate may be interested in reading further on the
>subject discussed. My first article was on 'booby trap code', a problem that
>affects programming languages such as Perl, MacPerl, C, C++, Java,
>Javascript, CGI, MVS and CICS. The second article describes the widespread
>programmer denial that I encountered. Initially, this denial was provoked by
>my research into the subject and then, later, further debate arose when my
>"booby trap code" article was published.
>For those interested, links to these articles can be found at URL:
>http://www.ts.co.nz/~finsol/y2k_articles.htm
Truth and substantive responses don't seem to please you. The person
who points out (correctly) that "you have nothing new to say about Perl
and Y2K" you dismiss as a resident of the "Ivory tower". The person who
states that "The tm_year member of a struct tm is an int, and is not
likely to (in fact, guaranteed not to) overflow values greater than 100"
falls into your "Head in the sand" category. And so on.
What exactly are you trying to get us to say? That tm_year *won't*
contain a useable value in 2000? That the Perl language itself *does*
have a "Y2K problem"? That this topic has *not* been talked about to
death? That you're pointing out things none of us have ever thought
about?
I have no insight into the origins or purpose of your crusade to be
annointed the Sage of Y2K, nor into your inclination to frame that crusade in
pop-psych terms. It does seem, though, that you are angling for some
sort of mass confession from everyone in the field (including all those
experts in the CGI programming language...). But I'm not sure what
everyone is supposed to confess *to*. Stupidity? Inexperience?
Failure to praise you?
If you tell us what it is, and we confess to it, will you stop bringing
this topic up?
David Black
dblack@pilot.njin.net
------------------------------
Date: Fri, 27 Nov 1998 03:00:40 -0600
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: Y2K and Programmer Denial
Message-Id: <365E6A38.6A1488FC@gatewest.net>
David Formosa wrote:
!
! In article <73kvbt$vjb$1@nnrp1.dejanews.com>, finsol@ts.co.nz wrote:
[snip ... stuff]
! In responce to your comments in "Y2K not wanted here" the Y2K was a
! FAQ, previously discussed. It was not on topic because it had
! previously been done to death.
uh oh... you're obviously in denial--- don't you know that documented
behaviour and FAQ's have no relevance in the face y2k FUD??!!
Ignorance of the law is no excuse --- but apparently not knowing what
the hell you are doing is a perfectly valid excuse for this author.
What the heck else can be done besides documenting the behaviour of
functions and providing a FAQ for those not interested enough to read
that documentation?
OH MY GOD! Perl isn't addition compliant ... I just tried to add a
couple things together and got a WRONG result!
$a = 42;
$b = "3 + 2";
$c = $a + $b;
print $c;
ack! (aka, "ook") this gives me 45! what's up with that?
And, what's more, anyone who tells me that this is expected behaviour
from the documentation is in denial if they think this isn't a
serious 'booby trap' in the Perl language! I mean, how could "3 + 2"
be a number and not be 5?
Oh heck, nevermind, the point will be lost on someone...and that
person will go ahead and write an article.
regards
andrew
------------------------------
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 4307
**************************************