[8325] in Perl-Users-Digest
Perl-Users Digest, Issue: 1942 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 20 15:12:36 1998
Date: Fri, 20 Feb 98 12:00:26 -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, 20 Feb 1998 Volume: 8 Number: 1942
Today's topics:
.pl considered harmful? (was Re: Running Perl) <Russell_Schulz@locutus.ofB.ORG>
Re: An easy question or two (Craig Berry)
Re: Avoiding $` (Craig Berry)
Re: Avoiding $` uri@sysarch.com
Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's et (Abigail)
Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's et twod@not.valid
Re: DBD/oracle, and LD_LIBRARY_PATH (John D Groenveld)
Delete record from fixed-length random access databases <Aniz@auctionz.com>
Re: Generic Config-file maintenance (Roy Culley)
Re: Growing cucumbers - (prev Content-type Question) <hsommer@micro.ti.com>
Re: Growing cucumbers - (prev Content-type Question) (Nathan V. Patwardhan)
Re: Help for Hashes !! (Craig Berry)
HELP! exec doesn't work properly! <lsj@bnl.gov>
Re: How the Hell do I...? (Mark-Jason Dominus)
Looking for Perl code to extract comments/tags from a C <BillSear@vnd.tek.com>
Re: Newbie Question about Perl and Server Side Includes (Billy Chambless)
Re: NEWBIE: .= <hsommer@micro.ti.com>
Re: NEWBIE: .= (Craig Berry)
Re: NEWBIE: .= <barnett@houston.Geco-Prakla.slb.com>
Re: Out of memory <zkessin@lhr-sys.dhl.com>
PERL CGI AUTHENTICATION (Ernest Axelbank)
Re: Perl constants like C constants? (Stuart McDow)
Pipe wierdness irishman@technologist.com
Re: Prisoners of the evil empire (Andy Lester)
Problems with gnuplot in perl CGI (Dale Wityshyn)
Referencing data in an array of arrays <norman.bunn@mci.com>
Re: Referencing data in an array of arrays <cmargoli@world.northgrum.com>
Regex: quoted or unquoted string? (Mark666769)
Re: Regex: quoted or unquoted string? (Craig Berry)
Sendmail with Perl (David Staschover)
Re: Sendmail with Perl (John Stanley)
Re: ts: Remove files in a PERL sript (brian moore)
Re: Year 2000 Compliance: Lawyers, Liars, and Perl <colin@medit3d.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Feb 1998 12:18:57 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: .pl considered harmful? (was Re: Running Perl)
Message-Id: <19980220.121857.1O2.rnr.w164w_-_@locutus.ofB.ORG>
tchrist@mox.perl.com (Tom Christiansen) writes:
>> c:\perl\bin>perl extension.pl
>
> Dot pl means library, not program.
is this a recent thing?
> Perl doesn't require it.
of course not. you can call your perl scripts a.out . but why?
> And making anything else treat it specially can screw you
> over royally. See the p5p archives.
should we search for `royally'?
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: 20 Feb 1998 17:48:38 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: An easy question or two
Message-Id: <6ckflm$o2j$3@marina.cinenet.net>
Amy Hartman (amylynne@shadow.net) wrote:
: Sorry for the newbie questions; I'm still learning all the intricacies
: of Perl.
:
: 1) Is there any way for Perl to modify an already existing form that is
: being displayed on a web browser? (without rewriting the whole page)
: ie. a form field says "John" and you want Perl to change it to "Jane"
: without just a complete rewrite of the file.
Perl, in its role as one popular CGI language, doesn't 'know' anything
special about webpages, forms, browsers, or anything else. It just slurps
streams of text and environment variables, and emits other streams of
text. In other words, this isn't a Perl question, but rather a CGI or
browser question. See one of the CGI authoring newsgroups for support on
this sort of thing.
: 2) Is there any way for Perl to pass variables to Javascript? On the
: same token, how does Perl set or change cookies?
Ditto.
A good rule of thumb before posting a web-related question to c.l.p.m is
to ask yourself: Would I be having this same problem if I were writing my
CGI app in (say) C++? If the answer is 'yes', then the question doesn't
belong in c.l.p.m, but rather in a CGI authoring newsgroup.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 20 Feb 1998 17:39:59 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Avoiding $`
Message-Id: <6ckf5f$o2j$2@marina.cinenet.net>
Tom Grydeland (Tom.Grydeland@phys.uit.no) wrote:
: > why not just use
: >
: > /^(.+?)(a+)(.+?)$/
:
: surely you mean
:
: /^(.*?)(a+)(.*?)$/s
^
I believe the marked ? is meaningless and should be removed.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 20 Feb 1998 13:40:14 -0500
From: uri@sysarch.com
Subject: Re: Avoiding $`
Message-Id: <x7u39u2k8h.fsf@sysarch.com>
Tom.Grydeland@phys.uit.no (Tom Grydeland) writes:
> On 19 Feb 1998 23:05:13 -0500,
> uri@sysarch.com <uri@sysarch.com> wrote:
> > Joe Gottman <joegottman@nospam.worldnet.att.net> writes:
> >
> > > As most Perl hackers know, using $`, $&, or $' anywhere in a program
> > > can result in an enormous performance hit. It is easy enough to get the
> > > functionality of $& or $' by modifying the regular expression. If your
> > > basic regular expression is /a+/, you can emulate $& by using /(a+)/ ,
> > > and you can emulate $' by using /a+(?=(.*))/ (using positive lookahead
> > > and saving the result, this is legal according to 'Mastering Regular
> > > Expressions'). What is the best way of emulating $` ?
> >
> > why not just use
> >
> > /^(.+?)(a+)(.+?)$/
>
> surely you mean
>
> /^(.*?)(a+)(.*?)$/s
>
> //Tom Grydeland <Tom.Grydeland@phys.uit.no>
he never showed the data string. i assumed a single line for
simplicity. your addition may be more correct but doesn't address the
original problem (unless it is multiline).
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: 20 Feb 1998 17:27:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's etc.: a teacher's perspective...]
Message-Id: <6ckees$8n3$1@client2.news.psi.net>
Bart Lateur (bart.mediamind@tornado.be) wrote on 1634 September 1993 in
<URL: news:34f1445d.4580909@news.tornado.be>:
++ twod@not.valid wrote:
++
++ >I wish people would stop trying to rewrite history by changing the expansion
++ >of the letter F. It is, and always has been, 'Fucking' - apologies to those
++ >offended or shocked by the use of a word that is in most modern dictionaries
++ >(of any repute) and could I suggest that they use the alternate 'RTCM' (Read
++ >The Copulating Manual) acronym instead.
++
++ Why not create a censored version. Something like
++
++ RT*M
Grow up. This isn't the 50's.
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
------------------------------
Date: 20 Feb 1998 18:37:29 GMT
From: twod@not.valid
Subject: Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's etc.: a teacher's perspective...]
Message-Id: <6ckih9$1ek$1@vnetnews.value.net>
Nathan V. Patwardhan (nvp@shore.net) wrote:
: Because people are more reactive to the original, me thinks.
Agreed, there is nothing like listening to someone ask a question, pulling
the manual off the shelf handing it to the individual and uttering the
phrase in question.
I don't use it in a nasty way as I generally show the user where and what to
look at and consider. Most people take it as a learning experience and it
encourages them to think and do some research before they act.
IAP
--
I am using anti-spam measures, please replace 'not.valid' with 'value.net'
------------------------------
Date: 20 Feb 1998 14:44:28 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: DBD/oracle, and LD_LIBRARY_PATH
Message-Id: <6ckmes$g9m$1@tholian.cse.psu.edu>
In article <6cjk36$knl$1@delphi.et.tudelft.nl>,
T.J. Nijweide <tobias@socrates.et.tudelft.nl> wrote:
>I'm currently writing some scripts that use DBI and DBD::oracle. The
>problem I have is that oracle needs libclntsh.so.1.0, but that is not
>in the LD_LIBRARY_PATH for most users. I could of course write a wrapper
Did you install a binary version of DBD::Oracle? Did you install DBD::Oracle
and later change ORACLE_HOME? I dont understand why you have LD_LIBRARY_PATH
set.
John
groenveld@acm.org
------------------------------
Date: Fri, 20 Feb 1998 10:23:32 -0800
From: aniz Uhler <Aniz@auctionz.com>
Subject: Delete record from fixed-length random access databases
Message-Id: <34EDCA24.1061E3BD@auctionz.com>
Thank you for your help.
I have this problem. I can write to a file using the following syntax
in perl.
open(AA, "+<b") || die "Can't open ";
print AA pack("A40A40", $first, $last);
close(AA);
However when I want to delete a specify record in a file.
1) I want to use seek to move a particular record.
seek(AA, 80, 0)
What command or key word should I use?
Thank you for your help, I really appreciate it.
email: smixab@heart.engr.csulb.edu
------------------------------
Date: 19 Feb 1998 12:11:35 GMT
From: tgdcuro1@swissptt.ch (Roy Culley)
Subject: Re: Generic Config-file maintenance
Message-Id: <6ch7hn$qbn@gd2inews.swissptt.ch>
In article <6bapde$sa8$3@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> writes:
> [courtesy cc of this posting sent to cited author via email]
>
> Just make the config file straight perl! Anything else is dubious at best.
>
> --tom
Thats ok for perl hackers but what if the config file is maintained
by non-programmers?
--
Roy G. Culley Tel: +41 31 342 56 62
Dept. IS-B-53 Fax: +41 31 342 04 62
Swisscom Email: Roy.Culley@acm.org
Key fingerprint = 6B AD 68 79 30 0B C0 5F 16 BC 90 57 35 E9 FC 40
------------------------------
Date: Fri, 20 Feb 1998 11:43:01 -0600
From: Holly Sommer <hsommer@micro.ti.com>
Subject: Re: Growing cucumbers - (prev Content-type Question)
Message-Id: <34EDC0A5.B5B2CD25@micro.ti.com>
Nathan V. Patwardhan wrote:
: You're an extremely creative, college freshman who likes skipping
: CS113 and screwing around with Usenet. And probably even MUDDs.
Hey, now! I run one of those things :) And, it's MUDs, not MUDDs.
*grin*
-Holly, adding some "N" to S:N, sorry
------------------------------
Date: 20 Feb 1998 18:22:05 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Growing cucumbers - (prev Content-type Question)
Message-Id: <6ckhkd$62c@fridge.shore.net>
Holly Sommer (hsommer@micro.ti.com) wrote:
: Hey, now! I run one of those things :) And, it's MUDs, not MUDDs.
: *grin*
MUDD == Multiple Undergraduate Degree Destroyers
--
Nathan V. Patwardhan
------------------------------
Date: 20 Feb 1998 17:36:26 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help for Hashes !!
Message-Id: <6ckeuq$o2j$1@marina.cinenet.net>
Sylvain St.Germain (sgermain@nortel.ca) wrote:
: To do lookups I use the map function.
:
: %UserExists = map {$_, 1}, keys %AssocArr;
:
: $userid = "toto";
: if ($UserExists{'userid'} == 1) {
How's that any better than
if (exists $AssocArr{userid}) {
(which is also faster, shorter, and more comprehensible)?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 20 Feb 1998 13:49:07 -0500
From: "Lance" <lsj@bnl.gov>
Subject: HELP! exec doesn't work properly!
Message-Id: <6ckj0m$jkl$1@sun20.ccd.bnl.gov>
Hi,
I have the following lines in a perl script on HP-UX:
open(jj,">junk") || die "Couldn't open junk: $!\n";
print jj <<EOF; # line A
1
1
0
4
0
5
0
0
EOF
exec "trans.x < junk"; # line B
Note: "trans.x" is a Fortran executable file which uses "junk" as a
redirected input file
But it just doesn't work! line A does generate the file "junk", but line B
not only doesn't recognize "junk" but also makes it null.
If I comment line B and run the rest. It generates "junk". And then I
uncomment line B and comment the rest of it. (so "junk" already exits) and
run it. Line B works! I don't understand why they can't work together.
Since I'm new in Perl Programming, this could be a dumb question.
Any advice will be greatly appreciated!
--
Regards,
Lance
lsjATbnl.gov
------------------------------
Date: 20 Feb 1998 12:07:33 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: How the Hell do I...?
Message-Id: <6ckd8l$29f$1@monet.op.net>
Keywords: ancestor boil canoe colossal
In article <fl_aggie-1202981422100001@aggie.coaps.fsu.edu>,
I R A Aggie <fl_aggie@thepentagon.com> wrote:
>That's nice. That's also no excuse. I didn't know that, either. A quick
>persual of the Camel book - you _do_ have a copy, don't you? - would but
>you in the index, looking for "delete", yes? which points to the "delete"
>function on pg 156 of the Blue Camel, which has a curious note:
>
> It doesn't delete a file. See _unlink_ for that.
Yeah. The index also has an entry for
Deleting
files, 236
And what's at the top of page 236?
unlink
This function deletes a list of files...
------------------------------
Date: Fri, 20 Feb 1998 10:23:53 -0800
From: "William D. Sears" <BillSear@vnd.tek.com>
Subject: Looking for Perl code to extract comments/tags from a C source file
Message-Id: <6ckhlc$nmb$1@bvadm.bv.tek.com>
I am looking for a Perl program which will extract comments with embedded
tags from C source code. The purpose of this is to generate HTML files
which contain documentation for a C language API. I have looked at Perceps
and it does something similar to what I'm trying to do, but it's too much.
I'm looking for something much simpler. Basically, I just want to recognize
tags (like name, param, returns, etc.) and extract the information
associated with them so that I can feed this to a template to generate HTML.
I don't need any language parsing capabilities like what Perceps or Javadoc
do. I am figuring that there is code out there somewhere, does anyone have
anything that will do this?
Bill Sears
------------------------------
Date: 20 Feb 1998 19:08:29 GMT
From: billy@cast.msstate.edu (Billy Chambless)
Subject: Re: Newbie Question about Perl and Server Side Includes
Message-Id: <6ckkbd$fra$1@nntp.msstate.edu>
In article <01bd3db0$e17f59c0$ee02e0a9@itpla>, "Phil Anderson" <PAnderson@AMCTheatres.com> writes:
|> I am new to programming PERL and am having problems getting a Server Side
|> Include to function correctly.
|> My PERL script generates all the HTML and sends it to the browser, but the
|> server doesn't seem to recognize the <!--#include file="x.html"--> tag. By
|> that I mean it doesn't do the include, I see the tag as a comment in the
|> HTML source.
If the HTML output is correct, then your Perl is correct, and you have a
server problem.
It is vital when debugging CGI stuff to conceptually separate the
variious elements -- Perl, HTML, server idiosyncracies, browser
weirdnesses, etc.
So -- take it one step at a time:
Is the HTML correct? If you create a static HTML page with the includes
as you've described, does it include the named file properly?
If not, chances are either the files not there, or your server isn't
configured to do server-side includes.
|> I'm running PersonalWebServer Win95 with PERL version 5.003_07.
|>
|> Thanks in advance
|> --------------------
|> Phil Anderson
|> AMC Theatres
|> EMail: PAnderson@AMCTheatres.com
|>
|>
|>
|>
|>
|>
|>
--
* "And there _is_ a real world. In fact, some of you
* are in it right now." -- Gene Spafford
------------------------------
Date: Fri, 20 Feb 1998 11:28:15 -0600
From: Holly Sommer <hsommer@micro.ti.com>
Subject: Re: NEWBIE: .=
Message-Id: <34EDBD2F.DB941DB@micro.ti.com>
Seth Holcomb wrote:
: The book doesn't explain well what .= does; it just compares to +=.
: I am guessing this concatinates strings. Am I close?
Read a little further, or look at examples, and I'm sure you'll find
out, but yes... .= concatenates. += is an incrementing operator.
$foo= "Foo"; $foo .= "Bar"; print $foo;
would print "FooBar"
$foo = 1; $foo += 2; print $foo;
would print "3"
-Holly
------------------------------
Date: 20 Feb 1998 18:06:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: NEWBIE: .=
Message-Id: <6ckgmc$o2j$4@marina.cinenet.net>
Seth Holcomb (seth@e-zcomputers.com) wrote:
: Just started with Perl 5 for Dummies. I've examined several working
: scripts (3-11 pages) and understand it all perfectly... almost.
:
: The book doesn't explain well what .= does; it just compares to +=.
: I am guessing this concatinates strings. Am I close?
Very. '.' concatenates strings. 'op=', where op is any of a number of
operators (+ - / % . and so forth) is a combined op-and-assign-back
operator. So, for example,
$a = $a + 5;
$a += 5;
are equivalent, as are
$s = $s . $t;
$s .= $t;
Hope this helps!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 20 Feb 1998 12:23:10 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: NEWBIE: .=
Message-Id: <34EDCA0E.3476D5E6@houston.Geco-Prakla.slb.com>
Seth Holcomb wrote:
>
> Just started with Perl 5 for Dummies. I've examined several working
> scripts (3-11 pages) and understand it all perfectly... almost.
>
> The book doesn't explain well what .= does; it just compares to +=.
> I am guessing this concatinates strings. Am I close?
You are so close that your hair is on fire.
$variable .= "more stuff";
is the same as saying:
$variable = $variable . "more stuff";
Compare to += *= /= and -= of the Perl & C/C++ variety.
>
> Thanks
> --Seth
Dave
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
------------------------------------------------------------------------
* Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------
------------------------------
Date: 20 Feb 1998 15:38:10 +0000
From: Zachary Kessin <zkessin@lhr-sys.dhl.com>
Subject: Re: Out of memory
Message-Id: <m3pvkithgd.fsf@pc-hhu-52.lhr-sys.dhl.com>
Thomas Johansson <thomas.johansson@unisource.se> writes:
> Processing BIG ascii-files, 300 - 500 MB and 400 - 800 000 records each.
>
> Simple sequential read/write operations.
> The Perl-script crashes round record nr 640 000 with 'out of memory'.
> Solaris 2.5.1, 512MB memory and 2 GB swap.
> Anyone know why and how to get around it?
>
> Thomas
Dont try to have everything in ram at once, Read in a line and then
spit it back out
something like this
while (<INFILE>)
{
Do Something
print OUTFILE "$output";
}
Also turn on use strict, you probably have a memory leek somewhere,
useing "my" variables will probably help you fix it.
--Zach Kessin
------------------------------
Date: Fri, 20 Feb 1998 18:57:47 GMT
From: ernie@law.harvard.edu (Ernest Axelbank)
Subject: PERL CGI AUTHENTICATION
Message-Id: <34edd21d.3270485@fas-news.harvard.edu>
We've written some CGI scripts and plopped them in a sub-dir of
cgi-bin.
These cgi's are to be restricted to a group of about 12 individuals at
the site where we're working. I would like the users to be prompted
for
authentication every time a cgi is called (without having to exit
netscape).
Currently, once a user authenticates, they never have to
re-authenticate. I've tried TimeOuts and KeepAlives in 'httpd.conf'.
On a related note:
Is it possible to set a perl environment varible like:
$ENV{'REMOTE_USER'}="NULL";
I was thinking this might cause the user to have to re-authenticate.
Thanks for any help,
-Ernie & Mike.
ITS Systems Group
Harvard Law School
------------------------------
Date: 20 Feb 1998 17:59:27 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Perl constants like C constants?
Message-Id: <6ckg9v$439$1@ns1.arlut.utexas.edu>
mhoffman@ebnjhost.attmail.com writes:
>
> In C, it is possible to create .h files that simply contain
> constants that can be included by several different source files.
> Is there a similar way to do this in perl?
You could do something like this by creating a module. Set all your
constants in the import method. Then you can just say 'use
MyConstants;' in programs that use those constants.
You could even do a primitive kind of configuration management this
way.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
------------------------------
Date: Fri, 20 Feb 1998 12:26:47 -0600
From: irishman@technologist.com
Subject: Pipe wierdness
Message-Id: <6ckhst$f7r$1@nnrp1.dejanews.com>
I'm not a newby but I'm having a really wierd and stupid problem that is
driving me nuts. I'm trying to write a very basic web server which will only
execute cgi-bin scripts, not serve pages. To make things even more basic, I am
only trying to service "GET" requests - if I ever figure that out, I will move
on to "POST" requests which will be trickier since I need to use bidirectional
pipes. Anyway I've written a very simple test script based on the absolutely
bog-standard cgi-lib.pl package that everyone uses:
#!/usr/local/bin/perl5.002 -w
require "cgi-lib.pl";
if (&ReadParse(*input)) {
my $Top = &HtmlTop ("Testing");
print &PrintHeader, $Top, &PrintVariables(%input), &HtmlBot;
} else {
print &PrintHeader,
'<form><input type="submit"> Data: <input name="myfield">';
}
I've checked that I can run this from the command line after setting the
appropriate environment variables by hand. I've also written a wrapper as
follows:
#!/usr/local/bin/perl5.002 -w
$ENV{'QUERY_STRING'} = "a=1&b=2&c=3";
$ENV{'REQUEST_METHOD'} = "GET";
open (MYOUT, "sample.pl|") || die "open crapped out: $!";
print <MYOUT>;
close MYOUT || die "close crapped out: $!";
Both of these tests work fine, but the wierdness comes when I try to call
sample.pl from the server, which is based on the example in the perlipc man
page. The basic structure is:
# Open the socket, bind, listen - exactly as in the man page
for ( ; $paddr = accept(Client,Server); close Client) {
my($port,$iaddr) = sockaddr_in($paddr);
my $name = gethostbyaddr($iaddr,AF_INET);
logmsg "connection from $name [", inet_ntoa($iaddr), "] at port $port";
# Read the first line of the header.
$line = scalar <Client>;
($ENV{'REQUEST_METHOD'}, $file) = split (' ', $line);
$file =~ s/^\///; # Delete leading /
if ($ENV{'REQUEST_METHOD'} eq "GET") {
($file, $ENV{'QUERY_STRING'}) = split (/\?/, $file);
} # Not handling post method yet
# Some code to read client headers and set environment variables
if (!open (MYOUT, "$file|")) {
Notfound $file; # Subroutine to print "404 Not Found" page
next;
}
print Client "HTTP/1.0 200 OK\n";
while (defined ($_ = scalar <MYOUT>)) {print Client $_;} #LINE 76
close MYOUT || logmsg "close crapped out";
}
The server starts up ok, but when it gets a request it dies without sending
back any output:
cgisrv.pl 10747: server started on port 2345 at Fri Feb 20 10:45:26 1998
cgisrv.pl 10747: connection from [ snip ] at port 56696 at Fri Feb 20 10:45:32
1998
Use of uninitialized value at cgisrv.pl line 76, <MYOUT> chunk 16.
Use of uninitialized value at cgisrv.pl line 76, <MYOUT> chunk 16.
Unable to create sub named "" at cgisrv.pl line 76, <MYOUT> chunk 16.
%
The really wierd thing is that if I comment out the close statement in line
77, the client gets back the output it expects but the server still dies with
the same messages.
I've RTFM'ed, explicitly set the path to find the file, checked all the
obvious stuff, and tried every variation of line 76 I can think of but the
same shit keeps happening. I'm running perl 5.002 on SunOS 5.5.1. I can't
understand why it complains about uninitialised values when I'm being very
careful to distinguish between scalar and list contexts and to check for
undefined values. This is what I hate about perl - there are so many booby
traps, so much black magic and wizardry, and no matter how careful you are to
do everything carefully and conscientiously, and follow the examples exactly,
something like this trips you up - and if you are lucky, some perl guru will
take one look and say, "Well DUH... of course it doesn't work, you're not
doing X" where X is some utterly bizarre and obscure piece of black magic that
was stuck into the language in a geeky attempt at humor.
I know that there is something very basic and obvious (to the perl gods) that
I need to do to fix this, but I just can't find it. Will someone please take
pity on me and use their secret decoder ring before I beat my head to a bloody
pulp on the nearest wall? Thanks in advance.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 20 Feb 1998 17:32:08 GMT
From: petdance@maxx.mc.net (Andy Lester)
Subject: Re: Prisoners of the evil empire
Message-Id: <6ckemo$mjb$1@usenet88.supernews.com>
: The evil empire is Microsoft. Their prisoners are the poor souls who
: have never seen the guiding light of unix. :-)
It's so disingenuous to put the smiley at the end of your sentence there.
You'll make people think you're not 100% serious.
xoxo,
Andy
--
--
Andy Lester: <andy@petdance.com> http://tezcat.com/~andy/
Chicago Shows List: <shows@ChicagoMusic.com> http://ChicagoMusic.com/
------------------------------
Date: 20 Feb 1998 16:53:46 GMT
From: wityshyn@telusplanet.net (Dale Wityshyn)
Subject: Problems with gnuplot in perl CGI
Message-Id: <6ckceq$6tn$1@f02s02.tac.net>
I am trying to write a fairly simple perl CGI script on
an NT box.
I am using gnuplot to generate a GIF file from within
a CGI script.
The problem seems to have something to do with binmode on
STDOUT not being carried through to child processes.
This is the script:
print "Content-type: image/gif\r\n";
print "\r\n";
binmode( STDOUT );
open(GP,"|\\gnuplot\\gnuplot.exe");
print GP "set terminal gif\n";
print GP "plot x**3\n";
close GP;
If I have gnuplot output to a file and then print the file it
works fine.
Any suggestions on how to fix this would be appreciated.
Dale Wityshyn
wityshyn@telusplanet.net
------------------------------
Date: Fri, 20 Feb 1998 18:26:32 GMT
From: "Norman Bunn" <norman.bunn@mci.com>
Subject: Referencing data in an array of arrays
Message-Id: <sVjH.3596$Di1.192685@news.internetMCI.com>
Need some help referencing data in an array of arrays.
Here's the code fragment:
$counter3 = 0;
print hr;
while ($counter3 <= @profileHolder)
{
@temp = split(/:/,$profileHolder[$counter3]);
$profiles[$counter3] = @temp;
print hr;
print ("Counter3 is: $counter3");
print ("Description is: $temp[0] and $profiles[$counter3[0]]");
print ("SKU is: $temp[1] and $profiles[$counter3[1]]");
print ("Price is: $temp[2] and $profiles[$counter3[2]]");
print ("Part Number is: $temp[3] and $profiles[$counter3[3]]");
$counter3++
}
Where @profileHolder looks like:
Hewlett-Packard DeskJet 890Cxi:??????:111.11:C4555A#ABA
As I see it each print line should have the same data twice (two
descriptions, two SKUs, two part numbers). Instead I get:
Counter3 is: 0Description is: Hewlett-Packard DeskJet 890Cxi and 4SKU is:
?????? and 4Price is: 111.11 and 4Part Number is: C4555A#ABA and 4
It appears that $profiles[$counter3[3]] is returning the array size and not
the array entry value. There's probably a simple explanation for this,
right? Like references?
------------------------------
Date: Fri, 20 Feb 1998 18:44:06 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Referencing data in an array of arrays
Message-Id: <34EDCEF6.6FD6@world.northgrum.com>
Norman Bunn wrote:
>
> Need some help referencing data in an array of arrays.
>
> Here's the code fragment:
>
> $counter3 = 0;
> print hr;
> while ($counter3 <= @profileHolder)
> {
> @temp = split(/:/,$profileHolder[$counter3]);
> $profiles[$counter3] = @temp;
... code skipped ...
>
> It appears that $profiles[$counter3[3]] is returning the array size and not
> the array entry value. There's probably a simple explanation for this,
> right? Like references?
Yes. Saying
$profiles[$counter3] = @temp;
is using the array @temp in a scalar context, so the length is assigned
rather than the array contents. What you need to do is store
a reference to a copy of @temp. Don't store a reference to @temp
since you are re-using @temp on each iteration.
For example:
$profiles[$counter3] = [@temp];
would create an anonymous array and assign the reference.
Please read the man pages perlref, perldsc and perllol
for more info and examples.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: 20 Feb 1998 18:10:52 GMT
From: mark666769@aol.com (Mark666769)
Subject: Regex: quoted or unquoted string?
Message-Id: <19980220181001.NAA18515@ladder02.news.aol.com>
Hi,
I was looking for a regex that would match either:
1) a single quoted 'value'
2) a double quoted "value"
3) a value without any quotes at all
I tried this:
/([\"\']?)(.*?)(\1)*/
but obviously, if [\"\']? doesn't match, then \1 isn't
going to work.
Is there a way to check for all 3 conditions in a single Regex?
Thanks,
Mark
------------------------------
Date: 20 Feb 1998 19:21:22 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regex: quoted or unquoted string?
Message-Id: <6ckl3i$2nv$1@marina.cinenet.net>
Mark666769 (mark666769@aol.com) wrote:
: I was looking for a regex that would match either:
:
: 1) a single quoted 'value'
: 2) a double quoted "value"
: 3) a value without any quotes at all
:
: I tried this:
:
: /([\"\']?)(.*?)(\1)*/
:
: but obviously, if [\"\']? doesn't match, then \1 isn't
: going to work.
:
: Is there a way to check for all 3 conditions in a single Regex?
Not tested, but this should do the trick:
/(['"]).*?\1|[^'"]*/
...that is, a quote followed by zero or more other chars followed by a
matching quote, or zero or more non-quote chars.
Obviously, you'll need to anchor this pattern in some larger context,
since as written it matches on nothingness. If you want to make it match
the entire string, use
/^(?:(['"]).*?\1|[^'"]*)$/
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 20 Feb 1998 13:55:49 -0500
From: das@panix.com (David Staschover)
Subject: Sendmail with Perl
Message-Id: <6ckjjl$e16@panix.com>
Hi,
We are using Perl to send mail to a fairly large distribution list. The
list is Bcc'ed.. I have a few questions..
1) Is there a limit to the length of the bcc line?
2) I am finding that some of the recipients aren't receiving the mail. I
am using "sendmail -t". Are there extra sendmail commands I should be
using to ensure proper delivery? I remember reading somewhere in usenet
about some extra options to handle timeouts etc..
Thanks,
David Staschover
das@#panix.com
------------------------------
Date: 20 Feb 1998 19:53:12 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Sendmail with Perl
Message-Id: <6ckmv8$5au$1@news.orst.edu>
In article <6ckjjl$e16@panix.com>, David Staschover <das@panix.com> wrote:
>Hi,
>
>We are using Perl to send mail to a fairly large distribution list. The
>list is Bcc'ed.. I have a few questions..
>
>2) I am finding that some of the recipients aren't receiving the mail. I
>am using "sendmail -t".
Better solution than -t: create an alias using :include: and send mail
to that.
Or tell sendmail explicitly where to send the mail and then you don't
have to bother with a BCC line at all.
------------------------------
Date: 20 Feb 1998 18:41:42 GMT
From: bem@news.cmc.net (brian moore)
Subject: Re: ts: Remove files in a PERL sript
Message-Id: <slrn6erjk1.ujg.bem@thorin.cmc.net>
On 19 Feb 1998 20:36:50 GMT,
Craig Berry <cberry@cinenet.net> wrote:
>'Way technical'??? It's a bloody *programming language*! It's not
>designed for non-technical people to use, or even know about.
>
>As for explaining stuff thoroughly, the online Perl doc does a better job
>at this than any other language manpages/helpfiles/whatever I'm
>familiar with.
And the various perl docs (from the Llama and Camel, both editions, to
the online docs) are usually not only informative, but fun to read as
well.
Larry, Tom, Randal, and the rest of the people responsible for the Perl
docs did a great job of writing them. I wish the rest of my manpages
were as amusing and informative (Looking at the main 'perl' page right
now: the number of times and the number of ways that -w is suggested is
hilarious. It gets the point across with humor and style.)
------------------------------
Date: Fri, 20 Feb 1998 18:27:51 +0100
From: Colin Dooley <colin@medit3d.com>
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <34EDBD17.16475955@medit3d.com>
Steve Dover wrote:
>
> Time marches on, but by design, a given date or timestamp datam
> will only be allocated so many bits. At some point in time,
> more bits will need to be allocated. There's no way around it.
In a billion years the Sun will explode and you won't need to
worry about it any more. This suggests that a 64 bit time_t
ought to be enough...
--
<\___/>
/ O O \
\_____/ FTB.
------------------------------
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 1942
**************************************