[10941] in Perl-Users-Digest
Perl-Users Digest, Issue: 4542 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 4 11:07:21 1999
Date: Mon, 4 Jan 99 08:00:24 -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 Mon, 4 Jan 1999 Volume: 8 Number: 4542
Today's topics:
@ARGV in CGI scripts <r2-d2@REMOVEbigfoot.com>
Re: @ARGV in CGI scripts <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: @ARGV in CGI scripts <nospam_staffan@ngb.se>
Re: @ARGV in CGI scripts <r2-d2@REMOVEbigfoot.com>
Re: @ARGV in CGI scripts (Bart Lateur)
Re: @ARGV in CGI scripts dave@mag-sol.com
change perl script process name witthawat@excite.com
Re: change perl script process name <jdf@pobox.com>
Downloading files : help !! (Sven Delmeiren)
Help using Minivend with Apache <atech@mail.infoave.net>
Re: invoking a C function in a perl program (beginner) <Arved_37@chebucto.ns.ca>
Re: Is interpolation/parsing in s/// possible? (Bart Lateur)
London.pm January Meeting dave@mag-sol.com
NEW PASSWORDS TO BEST SEX PAGES haslawww@friko7.onet.pl
Obtaining filename In 'require' file unxgroup@liii.com
open new window? <schne050@umn.edu>
Perl Scripts on NT with Sounds <santoroj@netspear.co.uk>
Re: Perl, Netscape and Internet Explorer...:( <Tojo.Punnoose@Blr.Sni.de>
Programming Rules in Perl hai_long@bigfoot.com
READDIR doesn't work nemanij@hotmail.com
Re: READDIR doesn't work (Pythagoras Watson)
Re: READDIR doesn't work (Bart Lateur)
Re: SDBM in ActivePerl for Win32 : each() lose key/valu <alain.coetmeur@icdc.caissedesdepots.fr>
Re: SDBM in ActivePerl for Win32 : each() lose key/valu (robert)
Re: Security & Permissions: Why can't Perl read files f <design@raincloud-studios.com>
Re: Security & Permissions: Why can't Perl read files f <christopher.kuhi@stud.uni-muenchen.de>
Weird problem with map <pm@katz.cc.univie.ac.at>
Re: Weird problem with map (Geoff Kinnel)
what does this error mean? vivekvp@hotmail.com
Re: what does this error mean? dave@mag-sol.com
What's a language (non-perl) (was Re: Why Is Perl not a nick@macaw.demon.co.uk
Re: where are perl distribution pages found? dave@mag-sol.com
Re: Why Is Perl not a Language? nick@macaw.demon.co.uk
Re: Why Is Perl not a Language? <Aubreyh@bellsouth.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 4 Jan 1999 10:34:42 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: @ARGV in CGI scripts
Message-Id: <76q5io$74q$1@plug.news.pipex.net>
Hi all
Happy New Year!
Please could somebody explain briefly how @ARGV works with CGI scripts, I've
seen many scripts that pass the @ARGV to the script in the following way:
http://www.yourcompany.com/cgi-bin/cgi_script_name.cgi?user=fred&pass=fred&c
at=any
When I try passing this to a script it does not recognise any of the @ARGV.
if I do print "@ARGV"; it doesn't print anything.
Thanks for any help.
Artoo
------------------------------
Date: 04 Jan 1999 12:17:28 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: @ARGV in CGI scripts
Message-Id: <83aezz4793.fsf@vcpc.univie.ac.at>
Re: @ARGV in CGI scripts, Artoo
<r2-d2@REMOVEbigfoot.com> said:
Artoo> Please could somebody explain briefly how
Artoo> @ARGV works with CGI scripts, I've seen many
It doesn't!
Artoo> scripts that pass the @ARGV to the script in
Artoo> the following way:
Noooo they don't!
Artoo> http://www.yourcompany.com/cgi-bin/cgi_script_name.cgi?user=fred&pass=fred&c
Artoo> at=any
These aren't "command line" parameters, they are
passed as part of the CGI environment (QUERY_STRING).
The easiest way is to use the CGI.pm module and then
you can get at any of the CGI arguments like this:
use CGI;
my $user = param('user');
my @colours = param('spectrum'); # multiple selection
For much enlightenment:
$ perldoc CGI
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Mon, 04 Jan 1999 12:39:46 +0100
From: Staffan Liljas <nospam_staffan@ngb.se>
Subject: Re: @ARGV in CGI scripts
Message-Id: <3690A882.C27DE800@ngb.se>
Or try $ENV{ QUERY_STRING }
------------------------------
Date: Mon, 4 Jan 1999 12:16:30 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: Re: @ARGV in CGI scripts
Message-Id: <76qbhm$c6d$1@plug.news.pipex.net>
Thanks Tony,
Great help, It's that back to work fealing not thinking straight!
>The easiest way is to use the CGI.pm module and then
>you can get at any of the CGI arguments like this:
>
> use CGI;
>
> my $user = param('user');
> my @colours = param('spectrum'); # multiple selection
>
>For much enlightenment:
>
> $ perldoc CGI
>
>hth
>tony
>--
>Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
>Liechtensteinstrasse 22, A-1090 Wien, |
<URI:http://www.vcpc.univie.ac.at/>
>"You see? You see? Your stupid minds! | private email:
> Stupid! Stupid!" ~ Eros, Plan9 fOS.|
<URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Mon, 04 Jan 1999 12:29:28 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: @ARGV in CGI scripts
Message-Id: <3691b380.15840919@news.skynet.be>
Tony Curtis wrote:
>Artoo> Please could somebody explain briefly how
>Artoo> @ARGV works with CGI scripts, I've seen many
>
>It doesn't!
>
>Artoo> scripts that pass the @ARGV to the script in
>Artoo> the following way:
>
>Noooo they don't!
Have you actually tried it? :-)
Many servers, including that of my ISP (Apache) do actually pass some
variation on parts of the URL in @ARGV. Exactly WHAT it does, probably
depends heavily on the server's configuration.
Bart.
------------------------------
Date: Mon, 04 Jan 1999 14:12:14 GMT
From: dave@mag-sol.com
Subject: Re: @ARGV in CGI scripts
Message-Id: <76qi7t$s82$1@nnrp1.dejanews.com>
In article <76q5io$74q$1@plug.news.pipex.net>,
"Artoo" <r2-d2@REMOVEbigfoot.com> wrote:
> Hi all
> Happy New Year!
>
> Please could somebody explain briefly how @ARGV works with CGI scripts, I've
> seen many scripts that pass the @ARGV to the script in the following way:
>
> http://www.yourcompany.com/cgi-bin/cgi_script_name.cgi?user=fred&pass=fred&c
> at=any
>
> When I try passing this to a script it does not recognise any of the @ARGV.
> if I do print "@ARGV"; it doesn't print anything.
CGI scripts don't use @ARGV to get their arguments. You should probably read
some basic introduction to CGI before proceeding any further. Try doing a
search on CGI at <http://www.perl.com>.
hth,
Dave...
--
Dave Cross
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: Mon, 04 Jan 1999 08:52:51 GMT
From: witthawat@excite.com
Subject: change perl script process name
Message-Id: <76pvh3$dvi$1@nnrp1.dejanews.com>
I installed perl 5.004 on Solaris 2.6.I wrote perl script name "abc" and run
it. Then,I used "ps -ef | grep abc" and it show "/usr/local/bin/perl abc".
How can i change "/usr/local/bin/perl abc" to other process name such as
"bcd"?
Please send replies to my e-mail.
Thank you.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 04 Jan 1999 16:10:32 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: witthawat@excite.com
Subject: Re: change perl script process name
Message-Id: <m3btkfqdjr.fsf@joshua.panix.com>
witthawat@excite.com writes:
> How can i change "/usr/local/bin/perl abc" to other process name
> such as "bcd"?
See the $0 variable in the perlvar doc.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 04 Jan 1999 15:39:35 GMT
From: sdlmeire@mediaport.org (Sven Delmeiren)
Subject: Downloading files : help !!
Message-Id: <3690df06.5784717@news.uunet.be>
Hi everyone !!
I'm writing some sort of database containing files which can be
downloaded. However, I'd like to see who downloads which files.
Therefore I can use
print "Content-type: application/zip\n\n";
open (DL, "<test.zip");
while (<DL>) {
print ();
}
close (DL);
but, when the user gets the "Save as" window as to where he can save
the file, it doesn't show test.zip as the filename for the file to be
saved, but login2.cgi, the name of the cgi script. Can anyone tell me
how I can let it show up the correct filename ??
Thanks in advance,
Sven Delmeiren
------------------------------
Date: Mon, 4 Jan 1999 05:25:38 -0600
From: "Phil" <atech@mail.infoave.net>
Subject: Help using Minivend with Apache
Message-Id: <76q8ea$fjv$1@news3.infoave.net>
I am trying to run the perl shopping cart program minivend on a Win95 Apache
server. I have the newest version of activestate perl 5 and all the modules
needed to processdatabase scripts. I can get Minivend to start-up fine the
problem is I can not get Apache to run the sample catalog. I just cannot get
the two to communicate. I have messed around with the configuration files
trying to get it to hook up to Apache, but without any success. Everything
is in the default directory
Apache document root (http:// 127.0.0.1)
C:/Program Files/Apache Group/Apache/htdocs
cgi files
C:/Program Files/Apache Group/Apache/htdocs or
C:/Program Files/Apache Group/Apache/cgi-bin
and my sample catalog in Minivend is
C:\mvend\simple
What are the main variables I need to change in the configuration
files to make these two servers communicate.
------------------------------
Date: Mon, 4 Jan 1999 08:34:41 -0400
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
Subject: Re: invoking a C function in a perl program (beginner)
Message-Id: <Pine.GSO.3.95.iB1.0.990104082918.4109A-100000@halifax.chebucto.ns.ca>
This is what Perl extensions are about. You should take a look at perlxs
documentation.
In more practical terms, if you'd like an example, just post the C
function prototype, and someone (myself possibly) can show the conversion.
Or just email the info.
On Mon, 28 Dec 1998, olivier wrote:
> I must use a C function in a perl (CGI) script, the function is part of a
> library
> what syntax should i use ?
>
> the fact that the script call a function in a library, is it a problem (i
> have the Lib.h file).
------------------------------
Date: Mon, 04 Jan 1999 09:17:12 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Is interpolation/parsing in s/// possible?
Message-Id: <369383f7.3672505@news.skynet.be>
Tom Christiansen wrote:
> But this is a strange
>bunch of requirements, methinks.
What? The whole idea?
What if the pattern and the replacement are stored in a table, a text
file, with a lot of others? I've done it before, because it's far easier
for users (as opposed to programmers) to add new entries to the text
file, than to edit the source.
Bart.
------------------------------
Date: Mon, 04 Jan 1999 09:43:29 GMT
From: dave@mag-sol.com
Subject: London.pm January Meeting
Message-Id: <76q2g1$g4j$1@nnrp1.dejanews.com>
The January meeting of London.pm will be this Thursday, 7th January. We have
changed venues to Penderal's Oak which is on High Holborn about half way
between Holborn and Chancery Lane tube stations. We'll be in the Cellar Bar
from about 6:15pm.
Still no dancing canines, but Penderal's Oak does serve a drink called a
Thirsty Camel!
If you need any more details, please check our web page or contact me.
Dave...
--
Dave Cross
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: Mon, 04 Jan 1999 08:59:12 GMT
From: haslawww@friko7.onet.pl
Subject: NEW PASSWORDS TO BEST SEX PAGES
Message-Id: <369082de.289922@news.pw.edu.pl>
NEW PASSWORDS TO BEST SEX PAGES
http://friko7.onet.pl/wa/haslawww/
http://friko.internet.pl/~haslawww/
------------------------------
Date: Mon, 04 Jan 1999 15:00:03 GMT
From: unxgroup@liii.com
Subject: Obtaining filename In 'require' file
Message-Id: <76ql1j$uko$1@nnrp1.dejanews.com>
Within a "require" file I need to obtain the name of the "require" file
without hardcoding it. Is there a variable that contains this info?
Thanks!
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 4 Jan 1999 08:44:47 -0600
From: "Eric Schnell" <schne050@umn.edu>
Subject: open new window?
Message-Id: <76qk52$80j$1@news1.tc.umn.edu>
I want to create a form which accesses a perl script, and the results of the
script are printed in a new browser window. Any ideas on how to create a
new browser window from within the script?
Thanks in advance.
Eric, schne050@umn.edu
------------------------------
Date: Mon, 4 Jan 1999 14:46:38 +0000
From: "Joe" <santoroj@netspear.co.uk>
Subject: Perl Scripts on NT with Sounds
Message-Id: <01be37e9$1026f9d0$4d684692@ye12450>
Hi,
I'm using perl on NT to check for various processes.
When a process fails I want to be able to send sounds out to the users
indicating what's going wrong.
I have a number of wav files that I need to play but I am unsure how to
play them via a perl script.
Does anyone know how to do this ?
thanks
Joe...
------------------------------
Date: Mon, 04 Jan 1999 18:49:06 +0530
From: Tojo Punnoose <Tojo.Punnoose@Blr.Sni.de>
Subject: Re: Perl, Netscape and Internet Explorer...:(
Message-Id: <3690BFC9.E09425E1@Blr.Sni.de>
I got it corrected... Actually, it was the problem with the content type. When I
gave Content-Type = text/html it worked fine.... Sorry for the trouble
Tojo.
Jonathan Stowe wrote:
> On Fri, 1 Jan 1999 19:22:52 +0100 Thomas Turn Jensen wrote:
> > How come it should be a server problem when it works fine with some (in this
> > case IE) clients? I recon that it is the file extension - probably .cgi or
> > .pl - that the client (Netscape (sucks)) don't know what to do with(?)
> >
>
> Thats as maybe but it is the servers (or some CGI application) responsibility
> to set the correct Content-type header possibly based on the file extension
> thus it *is* a problem with the server if this is what is happening.
>
> Further if this is the case then it is probably non-standard behaviour on the
> part of the IE browser that is causing it to work there.
>
> Whatever the problem actually is it is still an problem with software other
> than Perl and thus I have set the followups accordingly.
>
> /J\
> --
> Jonathan Stowe <jns@btinternet.com>
> Some of your questions answered:
> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
> Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 04 Jan 1999 13:44:39 GMT
From: hai_long@bigfoot.com
Subject: Programming Rules in Perl
Message-Id: <76qgk7$qrk$1@nnrp1.dejanews.com>
I'd like to have some recommendations and rules to start Perl programming in a
correct way. I've seen some tutorials in Perl.
If you have an web site address for that please let me know.
Thank in advance
Anh LE
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 04 Jan 1999 10:21:27 GMT
From: nemanij@hotmail.com
Subject: READDIR doesn't work
Message-Id: <76q4n6$hrq$1@nnrp1.dejanews.com>
Hello,
Can anyone tellme why this doesn't work
opendir(THISDIR, ".") || die " Can't open $dir";
local(@filenames) = readdir(THISDIR) || die " can't read $dir";
closedir(THISDIR);
print "@filenames\n";
And alll the things that I get is a "." I tried to filter out the . file and
then saw what was there in @filenames. Then there was some arbitary no. (what
it meant I could not guess).
Can someone pls tell me how do I get all the files in this dir to the array
@filenames.
Thanks
Jagannath
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 4 Jan 1999 12:53:20 GMT
From: py@ecst.csuchico.edu (Pythagoras Watson)
Subject: Re: READDIR doesn't work
Message-Id: <76qdk0$9mf$1@hubble.csuchico.edu>
According to <nemanij@hotmail.com>:
: Can anyone tellme why this doesn't work
:
:opendir(THISDIR, ".") || die " Can't open $dir";
:local(@filenames) = readdir(THISDIR) || die " can't read $dir";
>From the perlop man page:
In particular, this means that you shouldn't use this for selecting
between two aggregates for assignment:
@a = @b || @c; # this is wrong
@a = scalar(@b) || @c; # really meant this
@a = @b ? @b : @c; # this works fine, though
readdir is returning only one thing, since it is being called in a scalar
context (provided by the || operator). Try something like (note "my" is
generally preferred to "local"):
(my (@filenames) = readdir(THISDIR)) || die " can't read $dir";
--
Py -- 3.141592653589793238462643383279502884197169399375105...
Pythagoras Watson -- "Live long and may all your kernels pop."
= py@ecst.csuchico.edu === http://www.ecst.csuchico.edu/~py/ =
------------------------------
Date: Mon, 04 Jan 1999 14:47:35 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: READDIR doesn't work
Message-Id: <3690d41b.24118885@news.skynet.be>
nemanij@hotmail.com wrote:
>local(@filenames) = readdir(THISDIR) || die " can't read $dir";
You're mixing list context and scalar context. That has an undesirable
effect. Besides, you don't need the " || die..." in this case, so just
drop it.
HTH,
Bart.
------------------------------
Date: Mon, 4 Jan 1999 11:51:23 +0100
From: "Alain Coetmeur" <alain.coetmeur@icdc.caissedesdepots.fr>
Subject: Re: SDBM in ActivePerl for Win32 : each() lose key/value
Message-Id: <76q6kv$7oq3@puligny.idt.cdc.fr>
Alain Coetmeur a icrit dans le message <76lo28$rms$2@platane.wanadoo.fr>...
>I'm using SDBM tied hashes in ActivePerl (508)
>I've discovered that SDBM does forget many keys
>with each()
I"ve dropped SDMB to use
DB_File (BSD database)
that works quite well.
I've installed it with the ppm installer
at activestate.com...
all run OK now.
SDBM seems really broken on win32
or maybe is it just a problem with the
limits of SDBM. (SMALL!)
anyway I've got a strange problem with DB_File.
in my ASP page the tie command randomly fail
(I die) and then works later...
I can cope with that if I detect and abort the page,
since the database is kept coherent.
------------------------------
Date: 4 Jan 1999 15:17:10 +0100
From: robert@il.fontys.nl (robert)
Subject: Re: SDBM in ActivePerl for Win32 : each() lose key/value
Message-Id: <76qih6$t3m@charm.il.fontys.nl>
"Alain Coetmeur" <Alain.Coetmeur@wanadoo.fr>:
>for a given key $k0 defined $rubrique{$k0} can be true
>yet
>while(($k,$r)=each(%rubrique))
>{
>}
>never find it !
I'm making a wild guess here, since I don't use either Windows or SDBM,
but: could it be that you're somehow adding and/or deleting key/data pairs
to/from %rubrique in the above while-loop? That's a big nono when dealing
with hashes, you see (which is also stated in the perlfunc manpage, in the
section about each()).
robert
------------------------------
Date: 4 Jan 1999 11:43:49 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Security & Permissions: Why can't Perl read files from the owner level?
Message-Id: <76q9hl$8bp@bgtnsc01.worldnet.att.net>
>If your OS requires mode 755 on a file before you can read it, then
>your OS is broken. Your OS should be requiring at least 400 for files
...
It doesn't work on my Linux box or from (pick one) any of 5 UNIX boxes
(no, I didn't configure those :) ) where my client's sites are
'reputably' hosted. There is something not right here, and I'm really
sick over it. Ted is right, they run fine from the command line on all 6
boxes. Yet none of them will work if called from a browser.
a simple test script... Will a few please try this and see if I'm just
nuts? Run it from a browser.. not the command line. I am curious how
many people will pass the test.
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
# secure directory should have permissions of 700
# idiot.dat should have permissions of 600 for this test
# idiot.dat contains the numbers 1 - 10 in rows
open (STUPID, "/home/bcg/cgi-bin/secure/idiot.dat");
while (<STUPID>){
$line = $_;
print $line;
}
close (STUPID);
# this is the error I get with a -w switch
# Read on closed filehandle at /home/bcg/cgi-bin/stupid.cgi line 12.
>Even if the program is being run under uid "nobody", that uid
>is certainly one of the set (user|group|other).
Do the files have to be owned by "nobody"? Like a chown?
>"How do I get the DB open routines to open a file in read-only mode?"
is
>a perl question. Whether it is answered in any of the documentation is
a
>different issue.
Thank you for your understanding. I have seen over 12 people having this
same problem from my searches in webBBS pages, newsgroups, etc today. No
one has an answer so far. Surely if I can discover the root of the
problem and solve it, then it should be covered in a doc somewhere and
will help others. It may not involve an algorithm, but it *does* involve
the direct execution (or lack of) Perl code. I see it as a valid FAQ
"Why can't I read a file with rw------ permissions on my server with my
script?" . It is a perfectly valid question.
CT
------------------------------
Date: Mon, 4 Jan 1999 16:47:06 +0100
From: "Christopher Kuhi" <christopher.kuhi@stud.uni-muenchen.de>
Subject: Re: Security & Permissions: Why can't Perl read files from the owner level?
Message-Id: <76qnqr$2as$1@sparcserver.lrz-muenchen.de>
Charles R. Thompson schrieb in Nachricht
<76q9hl$8bp@bgtnsc01.worldnet.att.net>...
<snip>
>sick over it. Ted is right, they run fine from the command line on all 6
>boxes. Yet none of them will work if called from a browser.
My tip: if something behaves differently from the command line than from a
browser...check the server config. Most servers have restrictions on what
can be read running from a browser, and in fact specifically restrict
reading in the /cgi-bin. I'm not sure about the details and whether this
applies to these scripts but check the docs for Apache (I assume that's the
server on your Linux box) - you probably won't be able to do anything about
the other ones...
Chris Kuhi
------------------------------
Date: 4 Jan 1999 14:33:56 GMT
From: Peter Marksteiner <pm@katz.cc.univie.ac.at>
Subject: Weird problem with map
Message-Id: <76qjgk$3g3u$1@www.univie.ac.at>
Consider the following example:
#!/bin/perl -w
use strict;
my @result;
my @array = ( "some\n", "junk\n" );
my $scalar = "more junk ";
$\ = "\n";
# Scalar constant: OK
@result = map { "more junk \n" } @array;
print "(1) Scalar constant\n @result";
# Scalar variable + something else: OK
@result = map { $scalar, $_ } @array;
print "(2) Scalar variable + something else\n @result";
# Numeric constant + something else: OK
@result = map { 54, $_ } @array;
print "(3) Numeric constant + something else\n @result";
# String constant + something else: Syntax error
#@result = map { "more junk ", $_ } @array;
#print "(4) String constant + something else\n @result";
# String constant in parentheses + something else: OK
@result = map { ("more junk "), $_ } @array;
print "(5) String constant in parentheses + something else\n @result";
This works as expected. However, if I uncomment case (4) I get a
syntax error:
syntax error at ./map.pl line 23, near "} @array"
Execution of ./map.pl aborted due to compilation errors.
A syntax error occurs whenever the first element is a string constant,
followed by anything else.
Is this a feature, a bug, or some subtle property of the map operator that
I don't understand?
Peter
------------------------------
Date: Mon, 04 Jan 1999 10:41:16 -0500
From: kinnelg@bms.com (Geoff Kinnel)
Subject: Re: Weird problem with map
Message-Id: <kinnelg-0401991041160001@d2465-hp4m.lvl.pri.bms.com>
In article <76qjgk$3g3u$1@www.univie.ac.at>, Peter Marksteiner
<pm@katz.cc.univie.ac.at> wrote:
>
> #!/bin/perl -w
> use strict;
> my @result;
> my @array = ( "some\n", "junk\n" );
> my $scalar = "more junk ";
> $\ = "\n";
>
<snip>
>
> # String constant + something else: Syntax error
> #@result = map { "more junk ", $_ } @array;
> #print "(4) String constant + something else\n @result";
>
> This works as expected. However, if I uncomment case (4) I get a
> syntax error:
Oddly (at least from my perspective), this works:
# String constant + something else: Syntax error
@result = map { qq{more junk }, $_ } @array;
print "(4) String constant + something else\n @result";
Don't know why, though. I thought qq{} and "" were equivalent. However,
perlop tells us:
"While we usually think of quotes as literal values, in Perl they function
as operators..."
geoff
------------------------------
Date: Mon, 04 Jan 1999 10:36:41 GMT
From: vivekvp@hotmail.com
Subject: what does this error mean?
Message-Id: <76q5jp$ik4$1@nnrp1.dejanews.com>
hi. i have a perl script that it not working. using perl -d <filename>, i
get this error:
Name "main::monitor" used only once: possible typo at menutest.cgi line 45.
there is not incidence of the work "main" at all in the script, and "monitor"
is only used 3x - here is the code:
#add extra price for monitors over 14"
$monitor = $input{'monitor'};
$price += $price_list{$input{'monitor'}};
using perl -w <filename>
i get this one too:
Can't locate cgi-lib.pl in @INC at menutest.cgi line 6
the lines of codes at line 6 are :
push(@INC,"/cgi-bin");
require("cgi-lib.pl");
1. where should cgi-lib.pl be located? in my cgi directory on my server? or
in my perl path?
2. what is wrong with the "main::monitor" line??
any help - please email!! thanx!!
--
May your bad hair days be few. This does not apply to the bald.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 04 Jan 1999 13:58:22 GMT
From: dave@mag-sol.com
Subject: Re: what does this error mean?
Message-Id: <76qhdu$rkr$1@nnrp1.dejanews.com>
In article <76q5jp$ik4$1@nnrp1.dejanews.com>,
vivekvp@hotmail.com wrote:
> hi. i have a perl script that it not working. using perl -d
<filename>, i
> get this error:
>
> Name "main::monitor" used only once: possible typo at menutest.cgi line 45.
> there is not incidence of the work "main" at all in the script, and "monitor"
> is only used 3x - here is the code:
>
> #add extra price for monitors over 14"
> $monitor = $input{'monitor'};
> $price += $price_list{$input{'monitor'}};
>
> using perl -w <filename>
>
> i get this one too:
>
> Can't locate cgi-lib.pl in @INC at menutest.cgi line 6
>
> the lines of codes at line 6 are :
>
> push(@INC,"/cgi-bin");
> require("cgi-lib.pl");
>
> 1. where should cgi-lib.pl be located? in my cgi directory on my server? or
> in my perl path?
cgi-lib.pl should be thrown away. You should be using CGI.pm which has been a
standard part of Perl for the last two releases. If you do insist on using
cgi-lib.pl then is doesn't really matter where you put it as long as Perl can
find it. This means either a) putting it in a directory that is already in the
@INC list or b) putting it in some other directory and then changing @INC to
include the directory where you put it. You have taken the second option.
Where you are going wrong is probably your call to push. It's very unlikely
that your cgi-bin directory is really called /cgi-bin. Your web server maps
calls to /cgi-bin to the correct directory. You need to find out where the
cgi-bin actually lives. Most web servers give you useful environment
variables that help you work this out. You might like to investigate
$ENV{DOCUMENT_ROOT} and similar variables.
> 2. what is wrong with the "main::monitor" line??
Nothing. But you're not using the value again. And you're probably not
declaring the variable using 'my'.
> any help - please email!! thanx!!
Posting for help here and expecting replies by email is very rude. If I've
taken the time to explain your errors, I'd like my response to be seen by as
many people as possible. This a) helps others woh may have the same problems
and b) (occasionally) prevents many people sending you the same advice.
hth,
Dave...
--
Dave Cross
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: Mon, 04 Jan 1999 11:34:18 GMT
From: nick@macaw.demon.co.uk
Subject: What's a language (non-perl) (was Re: Why Is Perl not a Language?)
Message-Id: <76q8vr$kv3$1@nnrp1.dejanews.com>
In article <Pine.HPP.3.95a.981212180404.6901B-100000@hpplus01.cern.ch>,
"Alan J. Flavell" <flavell@mail.cern.ch> wrote:
<snip>
>
> Perl satisfies all the usual requirements for being called a programming
> language. Conditionals and iteration and such.
Exactly, but be careful about what defines a language. Functional languages
have conditionals but don't have (or need) variables or iteration statements
to express complex ideas. E.g., given a function 'insert e l' to insert an
element 'e' into the correct position into a sorted list 'l', we might write
a sort function for a non-empty list as:
defun sort l {
if nil(tail(l)) { // If no tail of the list, i.e. just 1 elem
l // then return the list as it is
} else { // else
insert(head(l), sort(tail(l))) // return a list with the first list elem
// inserted into the sorted tail
}
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 04 Jan 1999 10:39:33 GMT
From: dave@mag-sol.com
Subject: Re: where are perl distribution pages found?
Message-Id: <76q5p5$imo$1@nnrp1.dejanews.com>
In article <36906750.CBC7162F@sympatico.ca>,
Eric B <aj2000@sympatico.ca> wrote:
> > First would be the several hundred "pages" of documentation that
> > are included with the perl distribution
> > itself.
>
> Can you clarify this a little more for me... i am a newbie and not too sure
what
> you mean by "perl distribution"
> Where can I get these pages and or the "dstribution"
The Perl distribution is set of files that you get when you download Perl to
install it on your computer. This includes everything that you need to build
and use Perl. Having successfully build and installed Perl (using
instructions included in the distribution), you can type 'perldoc perl' at
your command line to access the best free set of documentation that I've ever
seen[*].
Dave...
[*] Actually, it's better than most non-free documentation that I've seen.
--
Dave Cross
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: Mon, 04 Jan 1999 11:01:51 GMT
From: nick@macaw.demon.co.uk
Subject: Re: Why Is Perl not a Language?
Message-Id: <76q72v$jm2$1@nnrp1.dejanews.com>
In article <3672afb3.298023@news.skynet.be>,
bart.lateur@skynet.be (Bart Lateur) wrote:
> Thomas Brian Holdren wrote:
>
> >Subject: Why Is Perl not a Language?
>
> Because it's not Chinese? :-)
Hmm. As others have said, it is, of course, a language, just as any grammar
that allows us to express ideas is, no matter how simple or complex. In fact,
surely all languages that we use in relation to computers can reasonably be
called programming languages, as after all we are using them to program the
computer to do something or behave in a certain way. The more specific term
"scripting language" commonly applies to implemmentations of the language
interpreter that from the user's perspective allows code to be changed and
immediately executed without intermediate steps, e.g. languages for
applications like awk, sed, perl, sh, etc. They may also be quite simple
languages, such as specifying actions or rules in email programs, but
certainly need not be.
> Some points that may indicate a scripting language:
>
> 1) no user interface
Ha ha, oh the influence of Microsoft. A language, scripting or not, is a set
of rules defining a grammar for expressing ideas, and nothing to do with user
interfaces. These days to write programms most people use an editor of some
kind to edit the program text. Personally whether I am writing english, C++,
sed, sh, or programs for my own languages I usually use emacs, and this has
no bearing on the language I am writing.
> 2) stored as text, and, at earliest, compiled at startup.
Perhaps the most reasonable identification of a scripting language.
> 3) used to control other programs (this doesn't apply to Perl)
Sure it applies to perl, it controls the perl interpreter (or rather the
interpreter uses the programm to control itself), just as sh scripts control
the sh program. You could argue too that especially in the days of microcoded
processors, native machine binaries are also scripts, since they control the
program running within the CPU itself, but of course we don't conventionally
regard binaries as such.
Nick
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 04 Jan 1999 15:03:13 GMT
From: "Aubrey Hutchison" <Aubreyh@bellsouth.net>
Subject: Re: Why Is Perl not a Language?
Message-Id: <RK4k2.7082$Zk.2352942@news3.mia>
Perl == Practical Extraction and Reporting Language
Regards
Aubrey
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4542
**************************************