[16435] in Perl-Users-Digest
Perl-Users Digest, Issue: 3847 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 30 06:05:24 2000
Date: Sun, 30 Jul 2000 03:05:09 -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: <964951508-v9-i3847@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 30 Jul 2000 Volume: 9 Number: 3847
Today's topics:
Re: Better way to do this pattern match? <bart.lateur@skynet.be>
Re: CGI Execution URGENT (Mark W. Schumann)
Re: CGI Execution URGENT <glodalec@yahoo.com>
Confirming IP address and subnet mask <derek@fortstar.nospam.demon.co.uk>
Re: ecologically printed perldocs <bcaligari@shipreg.com>
Re: Forking question (Abigail)
Re: Forking question <templar318@earthlink.net>
Re: Forking question (Decklin Foster)
Re: Looking for domain hosting service with perl/php/my <tstel@yahoo.com>
metatags <randythefirstNOraSPAM@hotmail.com.invalid>
Re: Online RPG using SQL? aqutiv@my-deja.com
Re: Running other programs in background <templar318@earthlink.net>
Re: Running other programs in background <bart.lateur@skynet.be>
Re: Sockets <bart.lateur@skynet.be>
Using STDIN for email delivery (Lee Mahan)
wierd regular expression <john@booklyland.com>
Re: wierd regular expression (Craig Berry)
Re: wierd regular expression <anmcguire@ce.mediaone.net>
Re: wierd regular expression <uri@sysarch.com>
WIN32::NetAdmin <tschilbach@aodinc.com>
Re: WIN32::NetAdmin <tschilbach@aodinc.com>
Re: WIN32::NetAdmin <godzilla@stomp.stomp.tokyo>
Re: Wraping file with XML code <iltzu@sci.invalid>
Re: Writing HTML within Perl <newsposter@cthulhu.demon.nl>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 30 Jul 2000 08:47:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Better way to do this pattern match?
Message-Id: <apq7os42085usf0vvvkjrgvir2scoig218@4ax.com>
Jim Mauldin wrote:
>$search contains a reference to an anonymous CODE(0x87615e4) {! news to
>me !) which I assume contains Perl byte-code and has the advantage -
>here's the question - that the pattern is compiled only once and then
>evalauted over (0..zillion) lines, hence very efficient?
Don't forget to look at $sub, and see if it indeed does what you want. I
think I forgot '\b' style anchors.
And after this eval(), it is as if the contents of $sub were part of
your script source. So it's not just the patterns. For example, the code
will make use of '&&' shortcuts: if one pattern test fails, the rest
won't even be checked.
--
Bart.
------------------------------
Date: 30 Jul 2000 01:33:07 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: CGI Execution URGENT
Message-Id: <8m0emj$f3c@junior.apk.net>
In article <3981288F.1594@yahoo.com>, Mouse <glodalec@yahoo.com> wrote:
>#!/usr/local/bin/perl -w
>use CGI qw/:standard/;
>$sys = param('sys');
>print "Content-type: text/html\n\n";
>print "<HTML><BODY>\n";
>if( $sys )
>{
> @ARRAY=`rsh -l guest ${sys} ls -al`;
> foreach $A (@ARRAY)
> {
> print $A,"<BR>\n";
> }
>}
>print "</BODY></HTML>\n";
>
>If I run it manually from the UNIX shell, I get following result.
>
># myscript.pl
>(offline mode: enter name=value pairs on standard input)
>sys=machine1
>^D
>Content-type: text/html
>
><HTML><BODY>
>file1 file2 file3 file4
>file5 file6 file7 file8
></BODY></HTML>
>#
>As you can see, "rsh" was executed properly.
>But If I run the same script from Browser
>http://mymachine/cgi-bin/myscript.pl?sys=machine1,
>then "rsh" is ignored (well, it is not executed).
>Mode of myscript.pl is 755 which is to be ok.
Try putting the canonical "somehost rm -rf ~" into the sys form
variable. Think about what would happen on behalf of user "guest."
Please read "man perlsec" to answer your direct question (see "tainting")
and also to understand *why* tainting is important.
------------------------------
Date: Sun, 30 Jul 2000 09:43:02 +0200
From: Mouse <glodalec@yahoo.com>
Subject: Re: CGI Execution URGENT
Message-Id: <3983DC86.4B18@yahoo.com>
Rodney Engdahl wrote:
>
> In article <3981288F.1594@yahoo.com>,
> Mouse <glodalec@yahoo.com> wrote:
> > Hi !
> >
> > I have a small script:
> >
> > #!/usr/local/bin/perl -w
> > use CGI qw/:standard/;
> > $sys = param('sys');
> > print "Content-type: text/html\n\n";
> > print "<HTML><BODY>\n";
> > if( $sys )
> > {
> > @ARRAY=`rsh -l guest ${sys} ls -al`;
> > foreach $A (@ARRAY)
> > {
> > print $A,"<BR>\n";
> > }
> > }
> > print "</BODY></HTML>\n";
> >
> > If I run it manually from the UNIX shell, I get following result.
>
> when you run it manually, are you running it as the same uid as the
> webserver?
>
> >
> > # myscript.pl
> > (offline mode: enter name=value pairs on standard input)
> > sys=machine1
> > ^D
> > Content-type: text/html
> >
> > <HTML><BODY>
> > file1 file2 file3 file4
> > file5 file6 file7 file8
> > </BODY></HTML>
> > #
> > As you can see, "rsh" was executed properly.
> > But If I run the same script from Browser
> > http://mymachine/cgi-bin/myscript.pl?sys=machine1,
> > then "rsh" is ignored (well, it is not executed).
> > Mode of myscript.pl is 755 which is to be ok.
>
> is it ignored, or do you get 'permission denied' in the error log?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Thanks, that was a fault. Apache runs as NOBODY, since I tried to run as
other user. I added +nobody in .rhosts on servers, and now is ok.
------------------------------
Date: Sun, 30 Jul 2000 10:40:21 +0100
From: Derek Fountain <derek@fortstar.nospam.demon.co.uk>
Subject: Confirming IP address and subnet mask
Message-Id: <3983F805.692A3679@fortstar.nospam.demon.co.uk>
Can anyone point me to a piece of code which will take an IP address and
a subnet mask, and confirm that that IP address is valid for the subnet?
Much appreciated...
------------------------------
Date: Sun, 30 Jul 2000 09:25:05 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: ecologically printed perldocs
Message-Id: <8m0kkb$6c1$1@news.news-service.com>
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.GHP.4.21.0007291143211.3514-100000@hpplus03.cern.ch...
> On Sat, 29 Jul 2000, Brendon Caligari wrote:
>
> > ZCZC
>
> Good heavens! I haven't seen that used since half a lifetime.
>
> all the best
>
I used it only once...had set up a software for a journalist. The software
dialled into some london system used by journalists to post stories for a
particular newspaper. This was about 8 years ago. I kinda used to like
phrases like ++++, NO CARRIER, DIS, ZCZC, etc so at times used them to
'close off' messages
------------------------------
Date: 30 Jul 2000 00:23:46 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Forking question
Message-Id: <slrn8o7be6.vcg.abigail@alexandra.foad.org>
David Tsai (templar318@earthlink.net) wrote on MMDXXV September MCMXCIII
in <URL:news:39839968.2AD1B2BF@earthlink.net>:
..
.. A fork error is when an error occurs while trying to spawn a new child. The
.. $! variable contains a string that describes the error.
Well, glad we cleared that up. Come back again if you have another question!
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20000730
------------------------------
Date: Sun, 30 Jul 2000 08:24:46 GMT
From: David Tsai <templar318@earthlink.net>
Subject: Re: Forking question
Message-Id: <3983E629.4654A828@earthlink.net>
Hehe sorry about that.. I don't think I was thinking straight. I have been messing
with my code for 12 hours straight now.. Anyways I got my problem solved. I was
trying to spawn a child to mail each email address when I should be just spawning a
couple childs and splitting up all the work between them.
--
Best Regards,
David Tsai
CGI Paradise
http://www.web-consult.com/scripts/
------------------------------
Date: Sun, 30 Jul 2000 09:50:09 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: Forking question
Message-Id: <lTSg5.8435$f_5.38466@news1.rdc1.ct.home.com>
David Tsai <templar318@earthlink.net> writes:
> I am even using the "sleep" command to wait for some of the childs
^^^^^
> to end before spawning new ones so that it won't take up too many
> system resources.
Good idea, wrong way to go about it.
perldoc -f wait
--
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)
------------------------------
Date: Sat, 29 Jul 2000 21:03:02 -0700
From: Tom Stelzriede <tstel@yahoo.com>
Subject: Re: Looking for domain hosting service with perl/php/mysql
Message-Id: <57a7ossuv1h4i96ak9un5uajf6o3jptsaq@4ax.com>
On Wed, 26 Jul 2000 21:36:04 GMT,
jonceramic@nospammiesno.earthlink.net (Jon S.) wrote:
>On Fri, 21 Jul 2000 12:19:54 -0700, Tom Stelzriede <tstel@yahoo.com>
>wrote:
>
>>Can anyone recommend to me a domain hosting service that offers
>>perl/php/mysql and has reasonable pricing and good server response
>>time.
>>
>>Thanks,
>>
>>Tom
>
>www.cihost.com has a fairly cheap package with this and more.
>However, their techs don't always get things right when you call for
>support (or don't get back fast). But, they are friendly, and own up
>to mistakes. Their actual hosting has been pretty good with only one
>real outage (due to a domain name server screw up) within the last 9
>months.
>
>Jon
I'll be checking it out, Jon. Thanks very much for your help!
Tom
------------------------------
Date: Sun, 30 Jul 2000 02:11:49 -0700
From: randythefirst <randythefirstNOraSPAM@hotmail.com.invalid>
Subject: metatags
Message-Id: <158295b4.4d3f7f95@usw-ex0106-046.remarq.com>
Did search on meta/metatags/spiders, meta got hits, read most,
metatags none, spiders got 2, no help.
Question is, "Do the indexing spiders for search engines index
my perl scripts(.pl, .cgi) in the cgi-bin?"
Links would be great, I love to read.
Thank You in Advance for your time.
Randy
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Sun, 30 Jul 2000 09:15:57 GMT
From: aqutiv@my-deja.com
Subject: Re: Online RPG using SQL?
Message-Id: <8m0roc$ol7$1@nnrp1.deja.com>
In article <39835C84.CB79607F@gmx.net>,
jarcher@gmx.net wrote:
> I've been in the process of deveoping plans for an web-based
> role-playing game, and I'm looking at different ways to implement it.
> Several people have told me that the best way to go would probably be
to
> write it in Perl using a SQL database (for character stats, dynamic
> information, etc.) I'd appreciate any thoughts on this matter. Do you
> think the Perl/SQL combination would work, or are there better ways to
> implement such a project? Also, since my Perl skills are still pretty
> rough, if anyone could point me toward some online info about how to
use
> SQL from Perl I'd be very grateful.
>
> Thanks!
>
> James
>
Well, I don't know SQL at all, But I do like RPGs, so I think it'd be a
good idea, go for it. ;)
SQL or not, in perl When you do this type of stuff, I'd use some perl
OOP methods, etc... for example:
use RPGplayer;
use RPGitem;
$Player = new RPGplayer;
$Player->name('Jhon');
$Player->sex('male');
$inventory{'knife'} = new RPGitem;
Good luck.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 30 Jul 2000 08:33:22 GMT
From: David Tsai <templar318@earthlink.net>
Subject: Re: Running other programs in background
Message-Id: <3983E82D.DFED8375@earthlink.net>
The Fork: { } in the camel book is just a label for that block of code so
that it can redo that block of code in case of an error by the fork. You
should be using fork as a function .. something like this...
if($pid = fork) {
# This is the parent process.
}
elsif(defined $pid) {
# This is the child process so you would put your command here
`programname`;
}
else {
die "Fork Error: $!\n";
}
This may or may not work on a win32 machine.
--
Best Regards,
David Tsai
CGI Paradise
http://www.web-consult.com/scripts/
------------------------------
Date: Sun, 30 Jul 2000 08:58:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Running other programs in background
Message-Id: <r4r7os03fna4oboat1bdfs7v8e37obgmve@4ax.com>
ericr@yankthechain.com wrote:
>How can I make a Perl program run another program in the background?
>When I try `programname` it freezes the perl program until the called
>upon program has quit. Is there any way to do this?
You're running Win32, as I gathered from another post.
The simplest solution: do it through START:
system('start', 'programname');
which, however, may make a DOS window appear for a fraction of a second.
--
Bart.
------------------------------
Date: Sun, 30 Jul 2000 08:50:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Sockets
Message-Id: <d0r7os45t7ja0ie2a6dl96p2ilgqqacchm@4ax.com>
sturman wrote:
>I recommend the Perl Cookbook. It has some good, simple examples for
>UDP and TCP/IP client/server. Of course it is somewhere around $35-40.
>www.bookpool.com would probably have under $30. You can always look
>over it in a bookstore...
If I remember correctly, the book only contains a few *pages* (not even
a whole chapter) of socket code, without even an explanation on how it
works. This sounds like cargo cult style programming, promoted by the
"official source"...
--
Bart.
------------------------------
Date: Sun, 30 Jul 2000 06:53:35 GMT
From: lmahan@designwest.com(Lee Mahan)
Subject: Using STDIN for email delivery
Message-Id: <3983d0c5.59141939@news.pacbell.net>
Below is the script (at least the significant part):
#!/usr/bin/perl
while(<STDIN>)
{
$msg[$l] = $_;
$l++;
}
I'm then attempting to save it to a test file (That part works), but
nothing seems to be loaded in the msg array....how am I doing this
wrong?
************************************
This is the final test of a gentleman: His respect for
those who can be of no possible service to him.
--William Lyon Phelps, American educator (1865-1943).
***************************************
--Lee
Design West
Technology Consultant
System Administrator
------------------------------
Date: Sun, 30 Jul 2000 07:57:57 +0200
From: john <john@booklyland.com>
Subject: wierd regular expression
Message-Id: <3983C3E5.2BBC2C63@booklyland.com>
I have done the most simple regular expression, replacing a certain text
with the content of a variable:
s/text/$variable/gi
the expression is used several times, with different values of
$variable:
for example "text" is first replaced with "pig", later with "chicken"
and finally with "hotdog".
but - after using this expression once, it keep replacing the given text
with the first value of $variable, ignoring the new values - so the
string "text" will always be replaced with "pig" even if later $variable
is "chicken" or "hotdog".
is there a way to prevent this strange behavior?
--
John
------------------------------
Date: Sun, 30 Jul 2000 05:37:31 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: wierd regular expression
Message-Id: <so7for3vo0b73@corp.supernews.com>
john (john@booklyland.com) wrote:
: I have done the most simple regular expression, replacing a certain text
: with the content of a variable:
:
: s/text/$variable/gi
:
: the expression is used several times, with different values of
: $variable:
: for example "text" is first replaced with "pig", later with "chicken"
: and finally with "hotdog".
:
: but - after using this expression once, it keep replacing the given text
: with the first value of $variable, ignoring the new values - so the
: string "text" will always be replaced with "pig" even if later $variable
: is "chicken" or "hotdog".
: is there a way to prevent this strange behavior?
It shouldn't work that way, unless you're setting /o on the substitution.
Please post a brief code example which demonstrates the problem you're
seeing.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: Sun, 30 Jul 2000 01:07:18 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: wierd regular expression
Message-Id: <Pine.LNX.4.21.0007300104170.31604-100000@hawk.ce.mediaone.net>
On Sun, 30 Jul 2000, john quoth:
$$ I have done the most simple regular expression, replacing a certain text
$$ with the content of a variable:
$$
$$ s/text/$variable/gi
$$
$$ the expression is used several times, with different values of
$$ $variable:
$$ for example "text" is first replaced with "pig", later with "chicken"
$$ and finally with "hotdog".
$$
$$ but - after using this expression once, it keep replacing the given text
$$ with the first value of $variable, ignoring the new values - so the
$$ string "text" will always be replaced with "pig" even if later $variable
$$ is "chicken" or "hotdog".
$$ is there a way to prevent this strange behavior?
Well since you did not post any code, I will have assume.
After the first substitution, you have replaced 'text' with 'pig'.
Your string no longer contains 'text' so subsequent substitutions
will fail, and the text will remain with the word pig. If you
want to avoid this make a copy of your data before modifying it,
so that you can restore the copy when necessary.
anm
--
/*------------------------------------------------------------------------.
| Andrew N. McGuire |
| anmcguire@ce.mediaone.net |
| perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`' |
`------------------------------------------------------------------------*/
------------------------------
Date: Sun, 30 Jul 2000 06:39:54 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: wierd regular expression
Message-Id: <x7n1j03yv9.fsf@home.sysarch.com>
>>>>> "CB" == Craig Berry <cberry@cinenet.net> writes:
CB> It shouldn't work that way, unless you're setting /o on the
CB> substitution.
/o only affects the regex, not the substitution. and it is almost never
needed anymore as regexes are not recompiled unless a var being
interpolated into it has changed its value since the last time the regex
was executed.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 29 Jul 2000 23:16:41 -0500
From: "Timothy H. Schilbach" <tschilbach@aodinc.com>
Subject: WIN32::NetAdmin
Message-Id: <8m0a6s$fnt$1@news.chatlink.com>
Hello,
I am trying to make a simple password changer that allows people to input
passwords from a form on the website and then carry's those values over to
the PERL script which makes it so. Please can anyone tell me whats wrong
with the context of my script? I have included the script and errors I get
with it.
Script:
-------------------
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
}
use WIN32::NetAdmin;
$domain = aodinc.com;
UserChangePassword($domain, FORM{'username'}, FORM{'oldpassword'},
FOR{'newpassword'});
print "<H3>FORM('username'), your password has been changed as per your
request\n</H3>";
Errors:
-----------------------
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
Can't locate object method "FORM" via package "username" at
I:\aodinc.com\cgi-bin\chngpass.pl line 17
Thank you in advance....
--
Timothy H. Schilbach
Alpha Omega Design Inc.
tschilbach@aodinc.com
1-877-263-7094
Visit our website at www.aodinc.com
Highspeed internet connectivity and web hosting services
------------------------------
Date: Sat, 29 Jul 2000 23:32:45 -0500
From: "Timothy H. Schilbach" <tschilbach@aodinc.com>
Subject: Re: WIN32::NetAdmin
Message-Id: <8m0b4v$g96$1@news.chatlink.com>
Ok,
I just made a few changes:
1. I added the $ sign in front of FORM (which is how I defined it).
2. I get a new error now when I run the script. Its states that the
variable is not defined.
NEW ERROR:
----------------------
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
Undefined subroutine &main::UserChangePassword called at
I:\aodinc.com\cgi-bin\chngpass.pl line 17.
This UserChangePassword is a part of the Win32:NetAdmin module, how could it
be undefined? You can view that module and its subroutines at:
http://perl.aodinc.com where I have most all CPAN modules published for my
refrence.
Any Suggestions?
--
Timothy H. Schilbach
Alpha Omega Design Inc.
tschilbach@aodinc.com
1-877-263-7094
Visit our website at www.aodinc.com
Highspeed internet connectivity and web hosting services
"Timothy H. Schilbach" <tschilbach@aodinc.com> wrote in message
news:8m0a6s$fnt$1@news.chatlink.com...
> Hello,
>
> I am trying to make a simple password changer that allows people to input
> passwords from a form on the website and then carry's those values over to
> the PERL script which makes it so. Please can anyone tell me whats wrong
> with the context of my script? I have included the script and errors I get
> with it.
>
> Script:
> -------------------
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> local($name, $value) = split(/=/, $pair);
> $name =~ tr/+/ /;
> $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/<!--(.|\n)*-->//g;
> $FORM{$name} = $value;
> }
>
> use WIN32::NetAdmin;
>
> $domain = aodinc.com;
>
> UserChangePassword($domain, FORM{'username'}, FORM{'oldpassword'},
> FOR{'newpassword'});
>
> print "<H3>FORM('username'), your password has been changed as per your
> request\n</H3>";
>
>
> Errors:
> -----------------------
> CGI Error
> The specified CGI application misbehaved by not returning a complete set
of
> HTTP headers. The headers it did return are:
>
>
> Can't locate object method "FORM" via package "username" at
> I:\aodinc.com\cgi-bin\chngpass.pl line 17
>
>
> Thank you in advance....
>
> --
> Timothy H. Schilbach
> Alpha Omega Design Inc.
> tschilbach@aodinc.com
> 1-877-263-7094
> Visit our website at www.aodinc.com
>
> Highspeed internet connectivity and web hosting services
>
>
>
>
------------------------------
Date: Sat, 29 Jul 2000 22:53:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: WIN32::NetAdmin
Message-Id: <3983C2C6.F4EFF040@stomp.stomp.tokyo>
"Timothy H. Schilbach" wrote:
> I am trying to make a simple password changer that allows people to input
> passwords from a form on the website and then carry's those values over to
> the PERL script which makes it so. Please can anyone tell me whats wrong
> with the context of my script? I have included the script and errors I get
> with it.
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> local($name, $value) = split(/=/, $pair);
> $name =~ tr/+/ /;
> $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/<!--(.|\n)*-->//g;
> $FORM{$name} = $value;
> }
> use WIN32::NetAdmin;
> $domain = aodinc.com;
> UserChangePassword($domain, FORM{'username'}, FORM{'oldpassword'},
> FOR{'newpassword'});
> print "<H3>FORM('username'), your password has been changed as per your
> request\n</H3>";
> Errors:
> -----------------------
> CGI Error
> The specified CGI application misbehaved by not returning a complete set of
> HTTP headers. The headers it did return are:
>
> Can't locate object method "FORM" via package "username" at
> I:\aodinc.com\cgi-bin\chngpass.pl line 17
You have a minor but fatal typo here:
FOR{'newpassword'}
Should be $FORM('password') I believe. Correct
me if I am wrong. Your other FORM calls should
be in the format $FORM, dollar sign, FORM.
I am quite curious why you are using a stereotypical
message board / guest book line:
$value =~ s/<!--(.|\n)*-->//g;
Is this what you are running? If so, you have
some other concerns to address which I will
comment upon in closing, besides protecting
your password file.
There is some confusion on my part why you are
hardcoding a domain name when you should be
checking your user's domain name for a match.
If you are using a referrer variable for
security, this is not a good choice but it
will work, most of the time but far from
all the time. Use of an IP address is better
choice. You will not always get a domain name.
You will always get an IP address, perhaps the
right one or a fake one but not always a DNS.
As an alternative, you really do not need a module
for this operation and, you would be a lot better
off not using a module. Use of modules can be
an asset, a great helper, but modules should
be avoided whenever possible. Modules should
be a last ditch effort to avoid coding what
you don't know how to code or, modules should
be used when hand coding would be long and
complex. Other than this, modules are a plague.
Personal choice and personal opinion here.
This is one of those very rare times I will not
post full code and printed results. There is a
very simple solution, in words mostly rather
than code.
open your password file.
use slurp NOT while to reduce corruption risks.
make a backup copy with error checking.
create an array.
do a foreach loop...
if (${\index ($line, $domain)} gt -1) &
(${\index ($line, $FORM{username})} gt -1) &
(${\index ($line, $FORM{oldpassword})} gt -1)
{ $line =~ s/$FORM{oldpassword}/$FORM{newpassword)/; }
Use of a regex would be ok for this as well.
My perference is quick, very reliable index
for this type of operation.
Otherwords, test each line for three matches,
user's domain, username and old password. If
all three match, substitute and continue on
with your printing of each line to finish off.
Note, use of IP Address matching would be a
better choice than domain name.
How you write your code, what style you use,
is not as important as dumping this module
and keeping this simple. Again, a module
is a liability for this, not an asset, under
these circumstances perceived by me.
Only need a dozen lines, basically, to do what this
module is trying to do, with significant problems.
**
Use of a Brenner style read and parse, for what
I believe you are doing, is superior to cgi.pm
by all means. However, your other concern which
I touched upon earlier, is security. A Brenner
style read and parse beats cgi.pm hands down
each and everytime but you need to accessorize
your Brenner read and parse for security, such
as Content Length, meta characters and hostile
html tags so often used by jerks.
This site will introduce you to basic security:
http://www.eekim.com/pubs/cgibook/ch09/0902.html
I will strongly urge you to research and learn
about security issues, then incorporate security
techniques within your script, especially your
read and parse routine which currently displays
zero security.
In summary, dump the module, correct spelling
errors, check your syntax with a fine tooth
comb... open your password file, make a backup
copy with error checking, loop, match, replace,
print and close out. Piece of cake.
Give some thought to checking your user's
IP address rather than a hardcoded domain name.
This will increase your security right off, by
thirty-three percent.
Godzilla!
--
print "file:///%43|%2f";
------------------------------
Date: 30 Jul 2000 09:39:50 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Wraping file with XML code
Message-Id: <964949517.7949@itz.pp.sci.fi>
In article <39819FC8.CC279424@eurodyn.com>, Sasa Danicic wrote:
>I've need to wrap a binary file with a portion of XML-like code.
>XML-like code is something so called "an envelope".
Well, you could base64-encode it. The easiest way to do that in Perl
should be with pack "u" and tr/// - I think there's some example code
in the Camel book. Base64 data contains no XML metacharacters, so it
should be a simple matter of inserting it between appropriate tags.
(I think there's a base64 module, which would be even easier. I have
never used it, but searching CPAN for "base64" ought to help.)
--
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: 27 Jul 2000 19:23:58 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Writing HTML within Perl
Message-Id: <8lq28e$b9g$1@internal-news.uu.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
> Why does a print statement not always work when coded like this:
If you write it correctly it will work. If you write it incorrectly
it won't work.
> print <<HTML;
> <html><head><title>HTML Page</title></head><body><font size='3'
> color='#000066'>You are the $num visitor to this
> website.</font><BR></body></html>
> HTML;
This is incorrect:
Can't find string terminator "HTML" anywhere before EOF at xx.pl line 2.
Erik
------------------------------
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 3847
**************************************