[19968] in Perl-Users-Digest
Perl-Users Digest, Issue: 2163 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 20 09:10:27 2001
Date: Tue, 20 Nov 2001 06:10:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006265411-v10-i2163@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 20 Nov 2001 Volume: 10 Number: 2163
Today's topics:
Re: Perl generating JavaScript problem <bart.lateur@skynet.be>
Re: Perl generating JavaScript problem (Amer Neely)
Re: Perl generating JavaScript problem <bart.lateur@skynet.be>
Re: Screen Prints (Anno Siegel)
Re: send HTTP response <roger_faust@bluewin.ch>
system call (Eric)
Re: system call (Rafael Garcia-Suarez)
Re: system call <josef.moellers@fujitsu-siemens.com>
Re: system call (Tad McClellan)
Re: Traversing directories <bart.lateur@skynet.be>
WIn32::GUI ListView & Checkbox problem <news@filthaut.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 Nov 2001 09:09:15 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl generating JavaScript problem
Message-Id: <q37kvt879p4sil66o3ltr9c1fs905a1m8h@4ax.com>
Amer Neely wrote:
>Bart Lateur <bart.lateur@skynet.be> wrote in message news:<d7pgvtg216kqfjcdgkpr1n8740t61964m7@4ax.com>...
>> Amer Neely wrote:
>>
>> >> > and like this:
>> >> > my $SCRIPT_SRC = "http://127.0.0.1/cgi-bin/sql/mycd.js";
>>
>> Is this the proper URL for a browser coming from the outside world?
>
>It is when you run a web server at home to do your development on.
>127.0.0.1 is the IP address of the local machine. I develop my scripts
>at home before uploading to a server, and my box at home is not on the
>Internet, so I don't have to worry about the outside world.
OK... Can you get at the contents of that URL? For example, using
LWP::Simple, with a perl script on the client side, do you get a proper
file when you do:
use LWP::Simple;
print getstore("http://127.0.0.1/cgi-bin/sql/mycd.js",
"$ENV{TEMP}/test.js");
# should print 200, and save a usable Javascript source file in your
temporary directory
I suspect that your server is preventing downloading ordinary (static)
files from your cgi-bin directory.
The next step is: does the saved file look like what you'd ordinarily
put between "<script>" and "</script>" tags? No html, just plain
Javascript.
--
Bart.
------------------------------
Date: 20 Nov 2001 05:42:31 -0800
From: aneely@softouch.on.ca (Amer Neely)
Subject: Re: Perl generating JavaScript problem
Message-Id: <331f54ba.0111200542.1330cecc@posting.google.com>
Danny Aldham <danny@lennon.postino.com> wrote in message news:<9t9nov$1im$1@lennon.postino.com>...
> Amer Neely <aneely@softouch.on.ca> wrote:
> > "Mina Naguib" <spam@thecouch.homeip.net> wrote in message news:<Ar_I7.5771$Nq2.307478@weber.videotron.net>...
> >> On the web browser's side, do a "VIEW SOURCE". What does the above line get
> >> displayed as ?
>
> > It shows up as <script src="mycd.js"></script> or
> > <script src="http://127.0.0.1/cgi-bin/sql/mycd.js"></script> depending
> > on how I define it. In IE, the page loads fine, but as soon as a call
> [snip]
>
> You are expecting the webserver to parse & process this file like it
> would standard html. But because the file is not processed by the
> web server, the web server does not do the substitution you expect.
> You need to print out the contents of mycd.js in the output of your
> perl/cgi program.
I checked the Apache error.log and it has:
c:/httpd/cgi-bin/sql/mycd.js is not executable; ensure interpreted
scripts have "#!" first line
couldn't spawn child process: c:/httpd/cgi-bin/sql/mycd.js
So this points to a web config problem, not Perl.
------------------------------
Date: Tue, 20 Nov 2001 13:59:15 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl generating JavaScript problem
Message-Id: <maokvt4kasc88kt589k8e67cgbb3dk4osq@4ax.com>
Amer Neely wrote:
>I checked the Apache error.log and it has:
>c:/httpd/cgi-bin/sql/mycd.js is not executable; ensure interpreted
>scripts have "#!" first line
>couldn't spawn child process: c:/httpd/cgi-bin/sql/mycd.js
>
>So this points to a web config problem, not Perl.
What did you expect to happen?
If "mycd.js" is a pure Javascript source text file which is supposed to
be sent to the browser as is, as I would expect, then you need to make
it available in a location where the server doesn't expect anything but
scripts, i.e. NOT in cgi-bin.
--
Bart.
------------------------------
Date: 20 Nov 2001 12:23:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Screen Prints
Message-Id: <9tdhvh$6nm$3@mamenchi.zrz.TU-Berlin.DE>
According to D. Moore <rellmoore@hotmail.com>:
> Is there a command or function in PERL that's equivalent to the TPUT
> command in Korn Shell?
Do a CPAN search for tput (and probably termcap). See what you find.
Anno
------------------------------
Date: Sun, 18 Nov 2001 19:17:16 +0100
From: Roger Faust <roger_faust@bluewin.ch>
Subject: Re: send HTTP response
Message-Id: <3bfa25fe$1_1@news.bluewin.ch>
Alan J. Flavell wrote:
. If you really _do_ want ASCII CRLF (but that isn't entirely
> On Nov 18, Roger Faust inscribed on the eternal scroll:
>
> [following up to a rather confused posting that doesn't seem to have
> decided whether it's an HTTP transaction or a CGI script]
>
> > > The raw version (print "Status: 200 OK\n\n";) works ok so far (I
> > > think...) BUT if I try either of the following:
> >
> > \n\n isn't right, unfortunately, it works on most *nix, and lazzy people
> > are using it :-), maybe that's a bug. use \r\n\r\n
>
> Yet another case of someone who hasn't read perldoc perlport, it
> seems
> clear yet), the proper portable notation would be \015\012 in binmode.
Thanks, I didn't know that until now (in fact, i've never read this docs,
maybe i have, you're right)
> There's a bit about newline representations in here:
> http://cvs.perl.org/cvsweb/perlfaq/perlfaq9.pod
> (thanks for the pointer, brian!) You probably want to click on
> "Revision 1.5".
>
> If this is a CGI question, I'll try to be more helpful about it when
> an updated version of the question appears on c.i.w.a.cgi [1]
>
> > the seems to be a problem with the modules,
>
> does there, indeed?
if one gets an error from a modul, i think it's so
>
> > check the docs for more information
>
> Now you're talking.
>
you're right again....
sorry for confusing
--
Roger Faust
------------------------------
Date: 20 Nov 2001 04:58:18 -0800
From: eric.chin@pinnacle.co.uk (Eric)
Subject: system call
Message-Id: <d8c847cd.0111200458.542bf0db@posting.google.com>
Greetings,
I am new to perl programming and I am trying out some of the functions.
I am puzzle by the system function call. I have the following:
$a = "file1.txt";
$b = "file2.lis";
$rtv = system ("cp $a $b") || die "copy failed: $!";
The above code cause die funtion to execute with the following messages:
"copy failed: No such file or directory at ./prog.pl line nn."
The copying process itself works as 'file1.txt' is copied to 'file2.lis'.
Whereas:
$rtv = system "cp", "$a", "$b" || die "copy failed: $!";
works without any errors.
Have I done something wrong ?
Any pointer appreciated.
TIA
Eric
------------------------------
Date: 20 Nov 2001 13:22:51 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: system call
Message-Id: <slrn9vkmap.k35.rgarciasuarez@rafael.kazibao.net>
Eric wrote in comp.lang.perl.misc:
>
> I am new to perl programming and I am trying out some of the functions.
>
> I am puzzle by the system function call. I have the following:
>
> $a = "file1.txt";
> $b = "file2.lis";
>
> $rtv = system ("cp $a $b") || die "copy failed: $!";
Read the section on system() in perlfunc. system() returns 0 on success.
So you should write :
$rtv = system ("cp $a $b") == 0 or die "copy failed: $!";
or better :
$rtv = system ("cp",$a,$b) == 0 or die "copy failed: $!";
(this last form does not involve the launching of a shell, and is more
secure, because this way your are protected against the presence of
shell metacharacters in $a or $b)
> The above code cause die funtion to execute with the following messages:
>
> "copy failed: No such file or directory at ./prog.pl line nn."
>
> The copying process itself works as 'file1.txt' is copied to 'file2.lis'.
>
> Whereas:
>
> $rtv = system "cp", "$a", "$b" || die "copy failed: $!";
>
> works without any errors.
This line is equivalent to
$rtv = system ("cp", "$a", "$b" || die "copy failed: $!");
and, as "$b" is true, the die() is not executed.
You can use 'or' instead of '||', it has much lower precedence and will
do what you meant. See the perlop manpage for details about Perl
operators.
Moreover, quotes are not necessary in "$a" and "$b".
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Tue, 20 Nov 2001 14:37:39 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: system call
Message-Id: <3BFA5CA3.9A155AA9@fujitsu-siemens.com>
Eric wrote:
> =
> Greetings,
> =
> I am new to perl programming and I am trying out some of the functions.=
> =
> I am puzzle by the system function call. I have the following:
> =
> $a =3D "file1.txt";
> $b =3D "file2.lis";
> =
> $rtv =3D system ("cp $a $b") || die "copy failed: $!";
> =
> The above code cause die funtion to execute with the following messages=
:
> =
> "copy failed: No such file or directory at ./prog.pl line nn."
> =
> The copying process itself works as 'file1.txt' is copied to 'file2.lis=
'.
> =
> Whereas:
> =
> $rtv =3D system "cp", "$a", "$b" || die "copy failed: $!";
> =
> works without any errors.
> =
> Have I done something wrong ?
> =
> Any pointer appreciated.
They both work!
The perldoc page of system states that "The return value is the exit
status of the program". Also, a logical or can be short-circuited.
First case:
If the cp succeeds (which is apparently does), the return value is 0.
Now, since the first operand of the || is 0, the second one must be
evaluated to determine the value of the expression. You wouldn't even
get the error message (which is bogus) if the cp failed!
Second case:
The logical or binds more than the comma, so here, since the first
operand is non-zero, the second does not need to be evaluated. Here, you
wouldn't get any error message at all!
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Tue, 20 Nov 2001 14:01:01 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: system call
Message-Id: <slrn9vklgp.juu.tadmc@tadmc26.august.net>
Eric <eric.chin@pinnacle.co.uk> wrote:
>I am puzzle by the system function call. I have the following:
>
>$a = "file1.txt";
>$b = "file2.lis";
$a and $b are special variable names. It is a good idea to
avoid using them for things other than sorting:
perldoc -f sort
>$rtv = system ("cp $a $b") || die "copy failed: $!";
>
>The above code cause die funtion to execute with the following messages:
>
>"copy failed: No such file or directory at ./prog.pl line nn."
>
>The copying process itself works as 'file1.txt' is copied to 'file2.lis'.
>
>Whereas:
>
>$rtv = system "cp", "$a", "$b" || die "copy failed: $!";
^ ^ ^ ^
That is parsed the same as:
$rtv = system "cp", "$a", ("$b" || die "copy failed: $!");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
if $b is not one of the "false" values, then the die() can
*never* execute, even if the system() failed.
You also have some useless quotes there.
>works without any errors.
Try it with an intentional error, like:
$a = 'no_such_file';
the die() will *not* be executed.
So that alternative does not work correctly either, you just
didn't test the case where it works incorrectly :-)
>Have I done something wrong ?
You have two somethings wrong.
1) system() returns _zero_ when everything went OK, non-zero
when the call failed (to match the Unix convention rather
than the usual Perl convention)
2) || is very high precedence
To fix #1:
$rtv = system ("cp $a $b") and die "copy failed: $!";
^^^
^^^
To fix #2:
either use parens around the argument list:
$rtv = system("cp", $a, $b) && die "copy failed: $!";
or use the low-precedence "and" so that you don't have to
override precedence with parens:
$rtv = system "cp", $a, $b and die "copy failed: $!";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Nov 2001 09:26:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Traversing directories
Message-Id: <0h7kvtk9ininadkg253bmro3ibvc6ojm7m@4ax.com>
Tad McClellan wrote:
>Methinks you're applying for a negative scorefile entry.
>
>Perhaps Randal has a reason that you just do not know of. Do
>you know who Randal is?
Hmm... I think it's time for a new slogan, in the realm of "stop feeding
the trolls". It is: "stop slamming the newbies". Come out of your ivory
tower. It's time to think on how, what you (anybody) have written in one
post, looks like to ordinary people who have never seen anything by you
before.
Although Randal looks like a very nice guy to me, judging from his
website (I really like people who dare to appear silly) (for those who
don't know where it is, it's at <http://www.stonehenge.com/merlyn/>), a
situation pretty much like this has brought him in serious legal
trouble. OK, IANAL, but at least, it looks to me that way: to those who
have been (remotely) in touch with him, it seems odd that his
"arrogance" was what appears to have been the prime reason to prosecute
him. See the closing statement of the trial at
<http://www.lightlink.com/spacenka/fors/court/pclose.txt>:
"That arrogance is what brings him here today."
(ok I'll stop now)
Well, apparently, Randal's recent post appears equally "arrogant" to
this person. How can he know that Randal has been hammering this point
here, at least 20 times, last year alone. (estimate)
--
Bart.
------------------------------
Date: Tue, 20 Nov 2001 09:39:07 +0100
From: "Marc Filthaut" <news@filthaut.com>
Subject: WIn32::GUI ListView & Checkbox problem
Message-Id: <9td4rj$1opej$1@ID-100287.news.dfncis.de>
Hi,
I search for a solution to check some checkboxes in a ListView.
I the object TreeView there is a method ItemCheck(NODE,[VALUE])
is there no way to do this in a ListView.
Marc
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 2163
***************************************