[16618] in Perl-Users-Digest
Perl-Users Digest, Issue: 4030 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 16 06:05:38 2000
Date: Wed, 16 Aug 2000 03:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966420316-v9-i4030@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 16 Aug 2000 Volume: 9 Number: 4030
Today's topics:
Re: Accessing ODBC data using PERL <darwal@altavista.net>
Re: active perl and xitami (Colin Keith)
Re: ARRAY of HASH values (Colin Keith)
Re: ARRAY of HASH values (Anno Siegel)
Re: being able to change the name of a file on the serv <gellyfish@gellyfish.com>
Re: being able to change the name of a file on the serv (Colin Keith)
Re: Byte Size of a Scalar -- How? <Peter.Dintelmann@dresdner-bank.com>
Re: Byte Size of a Scalar -- How? (Colin Keith)
Re: Can't call a script from html created by another sc <robin@dancing-man.com>
Re: Certain Items in a string <godzilla@stomp.stomp.tokyo>
Re: Certain Items in a string <godzilla@stomp.stomp.tokyo>
Re: CHOMP not working (Colin Keith)
cookie problem <vicki@kr8.com>
Re: DBI <Peter.Dintelmann@dresdner-bank.com>
Re: DBI (Colin Keith)
Re: Dereferencing a hash in CGI.PM (Colin Keith)
Re: Embedded spaces in arrays <iltzu@sci.invalid>
Fork & Waitpid andrewjasper@my-deja.com
Re: Fork & Waitpid (Colin Keith)
Re: form (Colin Keith)
Re: how can I optimize a tied hash for speed <Peter.Dintelmann@dresdner-bank.com>
Re: How to capture CGI program .exe output, modify it a <barrybx@my-deja.com>
Re: How to capture CGI program .exe output, modify it a <barrybx@my-deja.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 16 Aug 2000 10:51:28 +0100
From: "DAWallace" <darwal@altavista.net>
Subject: Re: Accessing ODBC data using PERL
Message-Id: <8ndogb$6em$1@newsg1.svr.pol.co.uk>
Nice one guys - much appreciated. Looks like i've got some swotting to do!
Keep on keepin' on!
DAWallace
------------------------------
Date: Wed, 16 Aug 2000 07:53:33 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: active perl and xitami
Message-Id: <1Mrm5.139$DT4.3826598@nnrp2.clara.net>
In article <8ncm37$2kk$1@nnrp1.deja.com>, metza@my-deja.com wrote:
>Is it possible to get perl (active perl) to work with the Xitami
>webserver for windows?
This is not a Perl question, this is about the configuration of your
webserver. The answer is Yes. You can find details on how by checking the
documentation/reading the Xitami FAQ.
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Wed, 16 Aug 2000 08:10:18 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: ARRAY of HASH values
Message-Id: <K%rm5.140$DT4.3826997@nnrp2.clara.net>
In article <399A1A94.CA4@yahoo.com>, Mouse <glodalec@yahoo.com> wrote:
>Isnt that funny whenever I am asking something, I get tutorial of how to
>use variables,which names
>to use for variable etc...
Oh, I'm sorry, I figured since you'd missed the numerous references in the
documentation to the fact that Perl flattens arrays you were kind of new.
Perhaps we should start a grading system whereby you post the time you've
been playing with Perl, you know start a grading system ranging from script
kiddie to Guru.
*snort*
Your so damn ungrateful. Just because *you* might know this means *you*
should just accept that you're not following convention and ignore anyone's
comments. The convention is for a reason - because it can cause problems -
but obviously *you* know this.
Thankfully you're not the only person reading this group, there are a lot of
people out there who just read the posts to pick up answers and tips. To
critique someone's code is not a crime, in fact its often a damn good idea
because not only do you pick up things that are wrong, you pick up areas
where you can get problems, "Try using lexical variables via my() rather
than package variables" for instance.
Since the answer is already happily documented, perhaps next time you would
prefer people just told you to RTFM rather than explaining what you're doing
wrong and *why* you do/can/could have problems in other areas of your code.
Perhaps we shouldn't bother telling anyone to check the return values of
their open()'s either ... ?
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: 16 Aug 2000 09:24:05 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: ARRAY of HASH values
Message-Id: <8ndmjl$j5t$1@lublin.zrz.tu-berlin.de>
Mouse <glodalec@yahoo.com> wrote in comp.lang.perl.misc:
>Isnt that funny whenever I am asking something, I get tutorial of how to
>use variables,which names
>to use for variable etc...
Of course you do. You post sub-standard code, it gets criticized.
>Every variable I use has prefix "my", I just didnt write it, since I put
>an example from my head.
Oh yeah? So you decide to save your precious time by not typing
the prefix (it's not a prefix) "my" where it belongs. At least
three people take their time to patiently and laboriously correct
your mistake, along with other errors in your code that show little
understanding of how Perl works. Your complaint is ridiculous
and insulting.
>I just needed a simple answer to solve my problem. And I got it.
>First change I needed was push(@ARRAY,{%rec}) instead of
>push(@ARRAY,%rec)
...the most inelegant and inefficient of the solutions you were
offered.
>Second, I must use $HASH->{name} instead of $HASH{name}
No. You're cutting corners again, at the expense of your readers.
You must use $ARRAY[ $i]->{name}, and not doing so in the first
place demonstrates a regrettable lack of skill in using Perl.
You just made sure that people will think twice before considering
to help you again.
Anno
------------------------------
Date: 16 Aug 2000 08:13:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: being able to change the name of a file on the server, and open it while keeping the old name
Message-Id: <8ndeup$h0p$1@orpheus.gellyfish.com>
On Mon, 14 Aug 2000 22:38:41 GMT arthur wrote:
> Hi all,
>
> Suppose there is a file that runs in a learning application on a server and
> I want different people to be able to change that file and save the version
> they changed as their own but not erase the other peoples version?
>
> In other words:
> Lets say GAME uses: filex. filex is on a server with public priviliges so
> people can change that part of the game. I want a perl script that will
> allow people to chage filex and save it with the name they want but it will
> still be known as filex because that is what GAME needs to run.
>
> I hope that is clear. Does anyone know of a script like that?
>
> or if I were to write one I think I would use a symlink
> but I have never used one before so any help is appreciated!
>
I think you've got symlinks the wrong way round - a file can be known by
a number of different names but a single symlink can't represent several
different files.
This is an application design matter - I think you will want to rethink
how you have default and personalized configuration files.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Wed, 16 Aug 2000 08:31:27 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: being able to change the name of a file on the server,(here is the script)
Message-Id: <zjsm5.141$DT4.3828085@nnrp2.clara.net>
In article <B5BE4EEE.5C6B%star@sonic.net>, arthur <star@sonic.net> wrote:
>I am sure you are not stupid I am just trying.
That still doesn't stop me missing the obvious, or not understanding what
yuo're trying to achieve.
>A few questions-- what is gid_of_copier? I know uid is user id but gid? Do I
>need it if he permissions on this script are public in all areas?
Sorry, Group ID of the person who's copying the file. To be honest I don't
know how this works under Win32, I *think* that you can just set it to 0 or
some such. stat() a file and see what numerical group ID is returned and use
that:
print 'GID of this file is: ', (stat('afile.txt'))[5], "\n";
You need the group ID when setting the ownership permissions on the file. If
everyone connecting is in the same class, I.e. with their account
details for that server, you can get the id from the passwd file. (see
the perlfunc man page for getpwnam()). If they're all accounts
that are only known via your CGI interface give the files the same group ID
as the group id of the webserver.
Oh, to change ownerships and group id's you will need to be have super user
priviliges, so your script will probably have to run setuid, which means you
definitely need a -T flag on the command line to turn on tainting (though
that's not a bad idea for any CGI script) and need to look over the perlsec
man page.
>I will get rid of the extra libraries. oops :>
Not a problem, just wondered if I'd missed something :)
>Also do you know Allan Fry he is a MacPerl gentleman in your area. He helped
>me alot a few years ago and I owe him a bottle of wine. I lost his address
>however.
My area? Er, sorry no, never heard of him:)
Actually, last time I got asked that was "Do you know X, she's the sister of
a friend of mine, she goes to the same university as you". Spookily, out of
the 4000-6000 people there .. I did. Can't remember who she was now though:)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Wed, 16 Aug 2000 10:46:33 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Byte Size of a Scalar -- How?
Message-Id: <8ndkdd$2lp3@intranews.dresdnerbank.de>
Hi,
Gabe schrieb in Nachricht ...
>File is uploaded via CGI, how can I learn its byte size so I can reject
>files too big.
if you intend to deny "huge" uploads check out
$CGI::POST_MAX (you have to set it before
creating your cgi object - see the documentation).
Best regards,
Peter Dintelmann
------------------------------
Date: Wed, 16 Aug 2000 09:03:01 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Byte Size of a Scalar -- How?
Message-Id: <9Nsm5.142$DT4.3829067@nnrp2.clara.net>
In article <spkc0n45r5j138@corp.supernews.com>, "Gabe" <grichards@flashcom.net> wrote:
>File is uploaded via CGI, how can I learn its byte size so I can reject
>files too big.
>I tried saying if ($bytesread > 70000) {Reject();} but Perl didn't
>understand.
Summary: RTFM
Verbose: "doesn't understand" is ambiguous. Tucked away at the bottom of the
CGI.pm man page is a description for a variable called $CGI::POST_MAX that
sets the maximum size of data it will allow in a POST. Read about/play with
that.
Also with file uploads in CGI.pm you get back a filehandle from param, so
you can use the -s operator (or stat()) to find out the information about
the size of the file pointed to by that handle. Plus have a look at
uploadInfo() in the CGI.pm docs.
This is off by default, you'd be better off fixing any 'problems' that
> while (my $bytesread = read($file,my $buffer,1024)) {
Ah, I see. $bytesread contains the number of bytes read for that call of
read() (or undef on errors), not a running total. At best its going to be
1024. You are also creating it as a lexical variable so it is only valid
within the scope in which you're using it. In this case, within the while
block:
while( .. ){ # from_here
# to_here
}
# not known about here
What you need to do is use a variable with a slightly wider scope in which
we keep a running total. We'll use another one:
maia% perl -w
my(@arr) = (1..5);
my($total) = 0;
while(my $var = shift(@arr)){
$total += $var;
print "\$var = $var ($total) ";
}
print "\n\$total: $total\n\$var = ", defined($var)?$var:'undef', "\n";
$var = 1 (1) $var = 2 (3) $var = 3 (6) $var = 4 (10) $var = 5 (15)
$total: 15
$var = undef
But as I say, explore the CGI docs :)
Col. - Eep, I obviously forgot to "use concise" :)
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Wed, 16 Aug 2000 11:06:28 +0100
From: "Rob" <robin@dancing-man.com>
Subject: Re: Can't call a script from html created by another script
Message-Id: <8ndoq7$6ue$1@news5.svr.pol.co.uk>
Thanks very much,
I tried almost everything you suggested and found no errors, however, I
htink I am on to something now. I changed the form methods to get instead of
post - something I should have done straight away, and it works - kind of -
It brings up the page fine, but for some eason does not set the cookie.
Still sets it on Apache though, I am learning to hate MS!
Any ideas why that may be?
------------------------------
Date: Wed, 16 Aug 2000 00:03:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Certain Items in a string
Message-Id: <399A3CDA.D0918939@stomp.stomp.tokyo>
Larry Rosler wrote:
> > marxjkj123 wrote:
mrxjkj123 sets his parameters:
> > > Result would should look like, $test = "Workarea\\WL_Property_WA";
My results match his parameters:
> > PRINTED RESULTS:
> > Workarea\\WL_Property_WA
Rosler lies:
> Which now has two backslashes where the original has just one.
My additional comments:
"Consider cleaning up your input data. Use of backslashes
for your path address are not needed in almost all cases.
Forward slashes work fine and will reduce the number of
hoops through which your script will have to leap.
Once you straighten out your data, these two snippets...."
What an ignorant hateful lying arse are you, so ignorant
you don't even understand why those snippets are included.
Lying without testing again, Rosler?
Normally I would question your reading comprehension skills,
Rosler. However, this time, you are simply flat out lying
with malice intent.
Might I politely suggest you vigorously shove your mule
manure within a place which will cause you significant
discomfort; right along side your head.
Godzilla!
------------------------------
Date: Wed, 16 Aug 2000 00:52:58 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Certain Items in a string
Message-Id: <399A485A.56B476A7@stomp.stomp.tokyo>
Larry Rosler wrote:
> [My apologies to Abigail, who (unless I also am plonked, which I doubt)
> will now have to see a Godzilla! post. Awareness of my power to infict
> such pain has inhibited me from responding several times already, but
> now I must yield to force majeur.]
Rosler, your very first utterances are of a serious
hateful nature holding great malice intent, much in
keeping with customary habit for regulars here.
During the course of your response, you carefully
deleted some my remarks to change context. Along
with this contextual lie, you mix in more hateful
remarks. This theme of your article, it is not one
of Perl issues, it is one of affording yourself a
chance to be repugnantly hateful, with disregard
for your personal image. Your article is pure hatred.
As stated recently, our family, myself, we practice
a zero tolerance policy regarding hatred. Your hatred
is repugnant and leads me to believe, like many others
here in this newsgroup, you are not of healthy mind.
Your hatred and routine expressions of hatred indicate
to me you are an uncivilized man of no worth to society,
in precise keeping with the collective demeanor of
this worthless news group and its regulars.
Your hatred may curl the lips of all others here into
a smug smile, but you have only garnished a look of
contemptuous distain from myself.
Work on your reading comprehension skills. You have
been snookered by your own hand, into revealing what
type of person are you truly, for all to witness.
As much as you would love to escape a backslash to
excuse your abhorrent behavior, you won't escape
this shameful display of sociopathic hatred fitting
only for a cretin, a display your unhealthy ego
commanded you to foolishly make a stage event.
"Result would should look like...."
*laughs*
However I am annoyed by this person's unconscious
idioms in writing; such deplorable grammar. He
will never wise up, nor will you, the reader.
Godzilla!
------------------------------
Date: Wed, 16 Aug 2000 09:26:37 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: CHOMP not working
Message-Id: <h7tm5.143$DT4.3829866@nnrp2.clara.net>
In article <3999F340.D7E08401@mail.com>, vrillusions@mail.com wrote:
>just me being picky ;)
That's cool.
>I was able to solve with just "$_[3] =~ s/\s+$//; # strip training
>CR/LF/space/fish" part. So it was one of those that was causing the problem.
I hope it wasn't the fish. They do get in odd places at times :))
>"Now that this half is done, now I have to set up the form processing script
>that writes the info people enter into the file" (ie, you'll probably being
>hearing more from me) ;)
Then some tips:
Don't trust the entered values. Ensure the name only contain letters.
Ensure the address only contain letters, numbers, comma, period and hyphen.
etc. The callsign should probably be allowed to contain anything. There are
people who use letters that don't match A-Za-z, but you should be okay if
you convert anything non alphanumeric to its HTML entity: &asc; where 'asc'
is its ASCII value. I'd ditch \0's and don't allow raw |. Also convert <, >
and & to their entities => (< > &) so they can't be used to embed
something icky.
You can do all of this using s/// which is the only way to untaint external
variables if you're using taint checking (-T when executing) See man perlsec
and I think CPAN and Perl.com have FAQ's/Tutorials on things to check
when writing CGI scripts but I don't have the URLs :)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sun, 13 Aug 2000 23:44:44 +0200
From: "Vicki Youll" <vicki@kr8.com>
Subject: cookie problem
Message-Id: <8n78b5$97n$1@venus.telepac.pt>
Hi,
I am having a problem with cookies when using the netscape communicator 4.6
browser and retrieving the stored data within the cookie . However, my code
works fine when using Internet explorer. I am writing a cgi program in perl
that issues the client with a cookie containing data in a hash data
structure. When i try to retrieve the data from the cookie on the clients
subsequent visits i retrieve no data from the hash, however i have no
problems with Internet Explorer and my program works as i expected. Here is
a small part of my program - to issue clients a cookie.
# here i am retrieving their cookie - clearing the data in the cookie and
assigning new data into the hash.
sub issue_cookie($) {
my ($hash_ref) = @_;
my ($date, $cookie);
my %dea;
$date = localtime;
%dea = cookie("dea");
%dea = ();
%dea = ( "name", "$hash_ref->{d_load}{d_contact_name}",
"email","$hash_ref->{d_load}{d_email}",
"date", "$date" );
$cookie = cookie ( -name => "dea",
-value => \%dea,
-expires =>'+30d');
print redirect (-url => "../dea/download3.html" ,
-cookie => $cookie);
exit;
}
# Here i retrieve data from the cookie and use the values in my html form.
Again i have no problems with internet explorer only netscape where the
assigned hash values appear to have gone!!
sub email_admin($) {
my ($hash_ref) = @_;
my ($email_msg, $email_subject, $msg, $dea_ver, $date);
my %dea;
if ($hash_ref->{d_load}{d_download_eng} or
$hash_ref->{d_load}{d_download_esp} ne "") {
$dea_ver = (($hash_ref->{d_load}{d_download_eng} ne "") ? "english" :
"spanish");
%dea = cookie("dea");
$date = localtime;
$email_msg = qq{ <html>
<head>
<style>
<!--
body{font-family:Arial,Swiss,Heltivica; color:"#000099"} -->
</style>
<title width="75%">DEA download url
requested</title></head>
<body>
<table align="center" width="50%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td align="middle" valign="baseline" width="100%"><IMG border=0
height=49 src="http://www.kr8.com/dea/images/dea5.gif" width=337></td>
<td></td>
</tr>
<tr>
<td valign="top" align="middle"><IMG border=0 height=28
src="http://www.kr8.com/dea/images/dea4.gif" width=337></td>
<td></td>
</tr>
<tr>
<td><br><br></td>
<td></td>
</tr>
<tr>
<td colspan="2">$dea{name} downloaded the $dea_ver
version of the Digital Estate Agent.</td>
<td></td>
</tr>
<tr>
<td><br></td>
<td></td>
</tr>
<tr>
<td>Requested dea url on:</td><td>$dea{date}</td>
</tr>
<tr>
<td>Downloaded the dea on:</td><td>$date</td>
</tr>
<tr>
<td>Email address:</td><td>$dea{email}</td>
</tr>
<tr>
<td align="middle" colspan="2"><a
href="http://www.kr8.com"><img
src="http://www.kr8.com/dea/images/kr8anim.gif" border="0"></a></td>
<td></td>
</tr>
</table>
</body>
</html> };
$email_subject = "DEA downloaded: \($dea_ver version\)";
} else {
$email_msg = qq{ <html>
<head>
<style>
<!--
body{font-family:Arial,Swiss,Heltivica; color:"#000099"} -->
</style>
<title>DEA download url requested</title></head>
<body>
<table align="center" width="50%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td align="middle" valign="baseline" width="100%"><IMG border=0
height=49 src="http://www.kr8.com/dea/images/dea5.gif" width=337></td>
<td></td>
</tr>
<tr>
<td valign="top" align="middle"><IMG border=0 height=28
src="http://www.kr8.com/dea/images/dea4.gif" width=337></td>
<td></td>
</tr>
<tr>
<td><br><br></td><td></td>
</tr>
<tr>
<td>Contact
Name:</td><td>$hash_ref->{d_load}{d_contact_name}</td>
</tr>
<tr>
<td>Company
Name:</td><td>$hash_ref->{d_load}{d_co_name}</td>
</tr>
<tr>
<td>Country:</td><td>$hash_ref->{d_load}{d_country}</td>
</tr>
<tr>
<td>Email:</td><td>$hash_ref->{d_load}{d_email}</td>
</tr>
<tr>
<td>Telephone
No:</td><td>$hash_ref->{d_load}{d_tel_no}</td>
</tr>
<tr>
<td>Fax:</td><td>$hash_ref->{d_load}{d_fax}</td>
</tr>
<tr>
<td align="middle" colspan="2"><a
href="http://www.kr8.com"><img
src="http://www.kr8.com/dea/images/kr8anim.gif" border="0"></a></td>
<td></td>
</tr>
</table>
</body>
</html> };
$email_subject = "DEA download url requested";
}
$msg = MIME::Lite->new
(From =>"$hash_ref->{d_load}{d_email}",
To =>'vicki@kr8.com',
Subject =>"$email_subject",
Type =>'text/html',
Data =>"$email_msg");
$msg->send;
if ($hash_ref->{d_load}{d_download_eng} ne "" ) {
print "Location: ../bin/dea.exe \n\n";
exit;
} elsif ($hash_ref->{d_load}{d_download_esp} ne "") {
print "Location: ../bin/id.exe \n\n";
exit;
} else {
return;
}
}
Also my cookie file has the correct assigned info in it on the client side
when i have been testing. Can any one help me with this problem. Thanks.
Vicki.
------------------------------
Date: Wed, 16 Aug 2000 10:19:51 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: DBI
Message-Id: <8ndirj$2ll7@intranews.dresdnerbank.de>
Hi,
Gennady Proschaev schrieb in Nachricht <399A355D.E4606ECC@fpos.agava.ru>...
>Hi, All!
>
>Does somebody help me?
what about yourself ;-)?
>Where can I get DBI module for my Perl?
>I'm using Win98/Apache/MySQL.
Have a look at the place where you got your
perl for Win98. If it is ActivePerl you will find
all you need at
http://www.activestate.com/packages/zips
Best regards,
Peter Dintelmann
------------------------------
Date: Wed, 16 Aug 2000 09:28:49 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: DBI
Message-Id: <l9tm5.144$DT4.3829892@nnrp2.clara.net>
In article <399A355D.E4606ECC@fpos.agava.ru>, Gennady Proschaev <webmaster@fpos.agava.ru> wrote:
>Where can I get DBI module for my Perl?
The majority of modules can be found on CPAN or one of its local mirrors.
http://www.cpan.org/modules/
You'll probably need a C compiler. Have a look at the MySQL web site, I
can't remember if they have a precompiled version for Win32.
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Wed, 16 Aug 2000 09:39:20 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Dereferencing a hash in CGI.PM
Message-Id: <cjtm5.145$DT4.3829653@nnrp2.clara.net>
This has already been answered, so for you, and others who didn't know:
In article <8nc33l$coq$1@nnrp1.deja.com>, joedevon@my-deja.com wrote:
>%testvars = ('t1'=>'r1',
> 't2'=>'r2',
> 't3'=>'r3');
Incidently, you can make your code neater (read type less:) by using a
feature of Perl to do:
%testvars = ( t1=>'r1',
t2=>'r2', ... );
(Note the lack of ''s around the keys. If it is a bareword (not quoted and
not a variable) before a => then its automatically quoted by Perl for you.)
Of course you could exploit this feature too:
%testvars = qw( t1 r1 t2 r2 t3 r3 );
Just to point out to you (and the lurkers:) some features that help you
type less :)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: 16 Aug 2000 08:04:24 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Embedded spaces in arrays
Message-Id: <966412475.22010@itz.pp.sci.fi>
In article <stevel-0708002302420001@192.168.100.2>, Steve Leibel wrote:
>
>In other words, interpolating an array in double quotes causes spaces to
>appear between the elements. Why is that?
Because interpolating an array in double quotes causes spaces to
appear between the elements. What did you expect?
Actually, print() inserts the value of the special variable $, between
its arguments, while array interpolation uses the value of $" instead.
By default, $, is the empty string and $" contains a space. All this
is documented in the "perlvar" manpage, among other places.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Wed, 16 Aug 2000 08:36:21 GMT
From: andrewjasper@my-deja.com
Subject: Fork & Waitpid
Message-Id: <8ndjq4$3t3$1@nnrp1.deja.com>
I'm using fork and waitpid, but waitpid keeps returning an error value
of 256 after the process has already been forked.
Does anyone have any ideas?
rb is a ymodem protocol program to receive data on the host computer.
$prog = "$rpi_dir/bin/rb" ;
# Forks new process
if( $pid = fork )
{
# Parent
# Wait for child to finish
waitpid( $pid , 0 ) ;
if( $debug )
{
print "PID $pid, Status $?.\n" ;
}
if( $? != 0 )
{
&error_log( "WAITPID returned Status $?" ) ;
$ret = -1 ;
}
}
elsif( defined $pid )
{
# Child code
print "I'm ready\n" ;
exec( $prog ) ;
exit( $ret ) ;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 16 Aug 2000 09:53:36 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Fork & Waitpid
Message-Id: <Awtm5.146$DT4.3830540@nnrp2.clara.net>
In article <8ndjq4$3t3$1@nnrp1.deja.com>, andrewjasper@my-deja.com wrote:
>I'm using fork and waitpid, but waitpid keeps returning an error value
>of 256 after the process has already been forked.
Ur, waitpid() returns the PID of the child when it dies or -1. If you're
always getting back.. ah, the exit code, that's not the same as the return
value :) *bops himself on the head for not reading everything first*:)
Check the docs (perlfunc) but afaik what you are seeing is the status code,
which when you /256 gives you the exit value of the program you just
executed. In your case 1. Since you're using exit($ret) aren't you just
getting back $ret where $ret = 1 ?
Also I think you should be using system() not exec() because system returns
and exec doesn't or summut which I'm sure the man pages explain clearly :)
>Does anyone have any ideas?
Many, but where are we going to find a inflatable shark at this time of
night, Brain ? :)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Wed, 16 Aug 2000 09:59:57 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: form
Message-Id: <xCtm5.147$DT4.3830639@nnrp2.clara.net>
In article <8nckb7$r0n$1@news.koti.tpo.fi>, "Sami Ylönen" <sami.ylonen@mediamikkeli.fi> wrote:
>I need to send same variable to 2 different perl programs
>using form How?
*sigh* This is a group for discussing Perl itself, not for discussing how to
code your HTML to send data to Perl scripts. I could reel off some crappy
way using javascript/frames/dhtml/popup windows, but you would get a much
better answer from someone in comp.infosystems.www.*
Of course that making assumptions. You *might* be wanting to have your Perl
program that processes data entered by a user via curses interface, from a
database via DBI or pulled from something via the OLE module (or maybe even
from e-mail) ... in which case you can call external programs using
open()
``
system() (exec())
depending on your needs. If the programs need to run simultaneously try
fork()'ing a child process to handle each file opening. ... but somehow I
think you're risking getting a crap answer from me that someone in one of
the above groups could answer much more clearly.
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Wed, 16 Aug 2000 11:01:48 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: how can I optimize a tied hash for speed
Message-Id: <8ndla0$2ln5@intranews.dresdnerbank.de>
Hi,
webqueen ; queen of the web schrieb in Nachricht
<8ncu4f$bqn$1@nnrp1.deja.com>...
>OK I ran some trials....
-- snip --
>Any thoughts?
Yes. Think on using the Benchmark module.
Best regards,
Peter Dintelmann
------------------------------
Date: Wed, 16 Aug 2000 17:13:54 +0800
From: barry <barrybx@my-deja.com>
Subject: Re: How to capture CGI program .exe output, modify it and then pass back to browser (client)
Message-Id: <399A5B52.4DC83D55@my-deja.com>
Hi ekkis,
Thanks for your help.
Barry
ekkis wrote:
> try a package called LWP (if you don't already have it, you can install it
> with the CPAN module: install Bundle::LWP). it comes with a module called
> Simple that provides a simple interface for such things. with it you could
> call the URL you mention, capture its output and do anything you like with
> it.
>
> - e
>
> <barrybx@my-deja.com> wrote in message news:8mg0d8$q00$1@nnrp1.deja.com...
> > Hi All,
> >
> > I'm a CGI dummy. This is a lengthy question, I really hope someone can
> help
> > (save) me.
> >
> > I have a CGI program with no source code, i.e. cgiprogram.exe.
> >
> > The arguments pass to the cgi program must use post method, like the
> > following:
> >
> > <form action=http://www.dummy.net/cgiprogram.exe method=post>
> > <input name=par1 value=val1>
> > <input name=par2 value=val2>
> > ...
> > </form>
> >
> > The output of the cgi program is directly return the browser (client). The
> > format of the output is binary Content-Transfer-Encoding and the
> > Content-type: text/html, i.e. somewhat like a binary html.
> >
> > I need to run the cgi program, get value from the output and redirect the
> > output (data) to another url (html page).
> >
> > That means:
> >
> > Originally,
> > cgiprogram -> output -> browser
> >
> > Intented to,
> > cgiprogram -> output -> another cgi program -> browser
> >
> > Do I need to write something like a cgi proxy program (that a big project
> to
> > me), or somewhat like a filter ?
> >
> > My main concern is how can I get the binary html data and redirect it to a
> > cgi program instead of printing to browser directory.
> >
> > Could anybody kindly give me some advice or suggestion?
> >
> > Recommended booklist or examples are welcomed.
> >
> > Thanks.
> >
> > Hope someone can understand my words.
> >
> > Best Regards,
> > Barry
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
------------------------------
Date: Wed, 16 Aug 2000 17:16:56 +0800
From: barry <barrybx@my-deja.com>
Subject: Re: How to capture CGI program .exe output, modify it and then pass back to browser (client)
Message-Id: <399A5C08.A2F008FB@my-deja.com>
Hi Bart Lateur,
Thanks for you suggestion. It's a good alternative.
Barry
Bart Lateur wrote:
> barrybx@my-deja.com wrote:
>
> >I have a CGI program with no source code, i.e. cgiprogram.exe.
> >
> >The arguments pass to the cgi program must use post method,
> >I need to run the cgi program, get value from the output and redirect the
> >output (data) to another url (html page).
>
> I assume you DON'T want this raw program to be directly on Internet?
>
> Maybe you could run this on a (your?) web server, through localhost, via
> the LWP module. Make sure people can't reach it from the outside. Hmmm..
> a firewall, and talking to your web server on a different than the
> default port, one that is blocked from the outside? Lots of work.
>
> Let's try the raw mode. Unless I'm mistaking, POST means that you must
> pipe the data into the program, for example from a file, after having
> set $ENV{REQUEST_METHOD} to "POST", and $ENV{CONTENT_LENGTH} to the
> length of the data string. Then, you're ready to run the program and
> capture the output. Finally, strip the header and parse the data.
>
> open OUT, ">$ENV{TEMP}/tempfile"; # or die...
> binmode OUT;
> print OUT $data;
> close OUT;
> $ENV{REQUEST_METHOD} = 'POST';
> $ENV{CONTENT_LENGTH} = length $data;
> $output = `cgiprogram.exe <$ENV{TEMP}/tempfile`;
> $output =~ tr/\r//d;
> $output =~ s/^(?:.+\n)+\n//;
>
> Er, something like that...
>
> --
> Bart.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4030
**************************************