[16509] in Perl-Users-Digest
Perl-Users Digest, Issue: 3921 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 5 03:05:34 2000
Date: Sat, 5 Aug 2000 00:05:11 -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: <965459111-v9-i3921@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 5 Aug 2000 Volume: 9 Number: 3921
Today's topics:
Re: File Manager Utility (William Herrera)
flock() on NT Server <jhisson1@columbus.rr.com>
Re: flock() on NT Server (Clinton A. Pierce)
Re: Game programming in perl...? (John M. Gamble)
Re: Gee, thanks for all the help :-( (Juho =?iso-8859-1?Q?Cederstr=F6m?=)
Re: get files from other servers (Keith Calvert Ivey)
How to capture CGI program .exe output, modify it and t barrybx@my-deja.com
keys with duplicate values in dbm files <milosk@flashcom.net>
Re: keys with duplicate values in dbm files jthornton@my-deja.com
LWP::Simple.pm b_e_n_d_e_r@my-deja.com
Re: My first module (Mark-Jason Dominus)
Re: passing spaces in URL <tony_curtis32@yahoo.com>
Re: passing spaces in URL jthornton@my-deja.com
problems with socket programming <none>
reg expressions - protect html <indiziert@unabomber.de>
Re: reg expressions - protect html (Abigail)
Re: reg expressions - protect html <callgirl@la.znet.com>
Re: reg expressions - protect html <callgirl@la.znet.com>
Re: reg expressions - protect html <gisle@ActiveState.com>
Re: Regexp problem - Stripping HTML (Keith Calvert Ivey)
Re: Regexp problem - Stripping HTML (Keith Calvert Ivey)
Re: Regexp problem - Stripping HTML (Abigail)
Secured login form submission <gwcyw@yahoo.com>
Re: semijoin() - a better way? (Keith Calvert Ivey)
Re: semijoin() - a better way? (John M. Gamble)
Re: String to Integer -- but oct/hex not converted! <tina@streetmail.com>
Re: Subclassing an opaque class (Damian Conway)
Re: Tk module for Windows NT (Homer Simpson)
Re: very cool routine (Greg Andrews)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 05 Aug 2000 02:52:01 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: File Manager Utility
Message-Id: <398b80c5.15102562@news.rmi.net>
On Fri, 4 Aug 2000 17:27:30 -0700, "VTAM_203" <VTAM_203@email.msn.com> wrote:
>copying files runs eventually on the OS, but the File::Copy module might
>help.
Usually the bad directory entries contain high ascii characters.
Use File::Find to get the whole direcory tree and skip such files. Then
File::Copy wil likely work to copy the others, or just a system "copy ...".
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
Date: Sat, 05 Aug 2000 03:08:54 GMT
From: "UnderMidnight" <jhisson1@columbus.rr.com>
Subject: flock() on NT Server
Message-Id: <azLi5.5858$IX6.47668@typhoon.columbus.rr.com>
Does flock() work on NT? I set up two test scripts, one would flock a file
(FLOCK_EX or 2) and sleep for about 30 seconds. During that time, I would
run another script that would also attempt to flock(FILEH, FLOCK_EX) and
attempt to read the file. With the file flocked by the one script, the
other script would still open the file and read from it.
The open statements in each script included the "+<" as I read in the man
pages that you may need to open a file for writing for the flock to work.
Even though the script that is reading the file is never writing to it. (i
am attempting to ensure that a file is not being changed while another
script is in mid read).
Thanks for your assistance!
-jason
--
"We've all heard that a million monkeys
banging on a million typewriters will
eventually produce the entire
works of Shakespeare. Now,
thanks to the Internet, we
know this is not true."
- Professor Robert Silensky, California University
------------------------------
Date: Sat, 05 Aug 2000 03:24:49 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: flock() on NT Server
Message-Id: <5OLi5.58020$fR2.591455@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <azLi5.5858$IX6.47668@typhoon.columbus.rr.com>,
"UnderMidnight" <jhisson1@columbus.rr.com> writes:
> Does flock() work on NT?
Generally, yes.
> I set up two test scripts [...]
But since you showed no code, we have no way of guessing what you
did wrong.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: 5 Aug 2000 04:26:26 GMT
From: jgamble@ripco.com (John M. Gamble)
Subject: Re: Game programming in perl...?
Message-Id: <8mg51i$5i5$1@gail.ripco.com>
In article <8mflpf$d8a$2@mark.ucdavis.edu>,
Adam Trace Spragg <spragg@cs.ucdavis.edu> wrote:
>Hey all. First off, let me say how glad I am to have found this newsgroup.
>I love everying Perl, and there seems to be a wealth of knowledge and helpful
>people here.
>
>I've been using Perl professionally and personally for almost a year now.
>I've always enjoyed game programming as a hobby, and in an effort to learn
>Perl better, I've created a play-by-email game. Perl was perfectly suited for
>this... reading in standard input files, processing the files, and creating
>the output which was then emailed off to the players.
>
>My next project is working on an online multiplayer "roguelike" game (using
>ascii graphics rather than traditional bitmaps). I've had a little bit of
>luck, but not enough time to get very far on it yet. At this point, multiple
>players (haven't tested an upper bound) can connect, and run around a couple
>of "maps", and talk to each other. It's pretty exciting.
>
>I'm wondering if anyone else is working on any such game-type projects in
>Perl. I'd be interested to hear what you're up to...
>
>Adam
Well, for what it's worth, i have a Games::Maze module under my ID
directory (JGAMBLE) in CPAN. It's only 0.001 (a direct translation
of some old Pascal code), but i am pretty close to releasing version
1.0, which will have a few improvements like only one module instead
of four, and hexagonal hex mazes.
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
--
Pursuant to US Code, Title 47, Chapter 5, Subchapter II, '227,
any and all unsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500
US. E-mailing denotes acceptance of these terms.
------------------------------
Date: 5 Aug 2000 05:51:18 GMT
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho =?iso-8859-1?Q?Cederstr=F6m?=)
Subject: Re: Gee, thanks for all the help :-(
Message-Id: <slrn8oliru.15r.cederstrom@sitruuna.cedenet.local>
On Thu, 03 Aug 2000 21:56:12 -0700,
Phil Hawkins <tarheel@sierratel.com> wrote:
> I have posted here twice in two days begging for help from you all and
> NO ONE seems to think my question merits anyone's attention.
What are you talking about? You got two followups which should be enough.
> Unix? Huh? I have to write two different scripts for each server
> type? And what about the compiler?
Michael Carman <mjcarman@home.com> answered this question:
"
No. [...] Perl is an interpreted language. That means that your
scripts can be run on just about *any* platform, [...]
"
Read his followup to see the complete answer.
> first scripts, it went belly up. I got wierd "Bare word found where
> operator expected"
The both followups explained what this is caused by. Didn't you read
them at all?
--
Juho Cederstrom - cederstrom<a>kolumbus.fi s/<a>/@/
------------------------------
Date: Sat, 05 Aug 2000 02:17:25 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: get files from other servers
Message-Id: <39907800.4656346@news.newsguy.com>
aaron@preation.com wrote:
>If I wanted to communited using a HTML form POST how what would I do, I
>use LWP::Simple right now for HTML form GET actions, but what about
>POSTS, can that be done? Any suggestions?
Unfortunately LWP::Simple doesn't handle POST requests. Gisle
(or whoever) had to draw the line somewhere, I suppose, or it
wouldn't be simple anymore. For POST requests, look at lwpcook,
which is part of the documentation that comes with LWP.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Sat, 05 Aug 2000 03:07:20 GMT
From: barrybx@my-deja.com
Subject: How to capture CGI program .exe output, modify it and then pass back to browser (client)
Message-Id: <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: Fri, 04 Aug 2000 22:21:50 -0700
From: lounge lizard <milosk@flashcom.net>
Subject: keys with duplicate values in dbm files
Message-Id: <398BA46D.DF723756@flashcom.net>
--------------1E9C36A25E241131BCEA4B62
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi: I seem to have more than one value for several keys in my dbm file
- it seems to return the latest value entered in the file - I'm trying
to delete the duplicates but am having problems - my script doesn't
delete the right values
basically I'm deleting from my dbm file %MAIN using
delete ($MAIN{$URL}); - doesn't that delete all multiple occurrences of
the key? or can I use
while (defined ($MAIN{$URL})) {
delete ($MAIN{$URL});
}
then reentering the values:
$MAIN{$URL} = $newvalue;
I have about 1000 keys to delete - doing it one at a time works
correctly but when I do a loop I run into problems even when I close the
dbm files on each loop. What am I doing wrong?
Sorry if this is a really dumb Q - I'm relatively new to Perl,
The relevant part of the script is below:
for ($id=1000; $id<15500; $id++) {
dbmopen (%ID, $keyIDdb, 0666) || die "can't open file\n";
dbmopen (%MAIN, $keyMaindb, 0666) || die "can't open file\n";
if (defined ($ID{$id})) {
$URL = $ID{$id};
$line = $MAIN{$URL};
chomp ($line);
@members_array=split(/\|/,$line);
if ($id != $members_array[11]) { #if there's a duplicate
$old_id = $members_array[11];
$members_array[11]=$id;
$newline = join ("\|",$members_array[0],$members_array[1]);
delete ($MAIN{$URL}); #deletes all duplicate values
from main db?
}
$MAIN{$URL} = $newline; #adds new value
delete ($ID{$old_id}); #deletes duplicate value from
id db
$i +=1;
}
}
}
dbmclose (%MAIN);
dbmclose (%ID);
}
--------------1E9C36A25E241131BCEA4B62
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi: I seem to have more than one value for several keys in my dbm
file - it seems to return the latest value entered in the file - I'm trying
to delete the duplicates but am having problems - my script doesn't delete
the right values
<p>basically I'm deleting from my dbm file %MAIN using
<p>delete ($MAIN{$URL}); - doesn't that delete all multiple occurrences
of the key? or can I use
<p>while (defined ($MAIN{$URL})) {
<br> delete ($MAIN{$URL});
<br> }
<p>then reentering the values:
<p>$MAIN{$URL} = $newvalue;
<p>I have about 1000 keys to delete - doing it one at a time works correctly
but when I do a loop I run into problems even when I close the dbm files
on each loop. What am I doing wrong?
<p>Sorry if this is a really dumb Q - I'm relatively new to Perl,
<p>The relevant part of the script is below:
<p>for ($id=1000; $id<15500; $id++) {
<br> dbmopen (%ID, $keyIDdb, 0666) || die "can't open file\n";
<br> dbmopen (%MAIN, $keyMaindb, 0666) || die "can't open file\n";
<br> if (defined ($ID{$id})) {
<br> $URL = $ID{$id};
<br> $line = $MAIN{$URL};
<br> chomp ($line);
<br> @members_array=split(/\|/,$line);
<br> if ($id != $members_array[11]) {
<b>#if there's a duplicate</b>
<br> $old_id = $members_array[11];
<br> $members_array[11]=$id;
<br> $newline = join ("\|",$members_array[0],$members_array[1]);
<br> delete ($MAIN{$URL});
<b>#deletes all duplicate values from main db?</b>
<br> }
<br> $MAIN{$URL} = $newline;
<b>#adds new value</b>
<br> delete ($ID{$old_id});
<b>#deletes duplicate value from id db</b>
<br> $i +=1;
<br> }
<br> }
<br> }
<br>
<br> dbmclose (%MAIN);
<br> dbmclose (%ID);
<br>}</html>
--------------1E9C36A25E241131BCEA4B62--
------------------------------
Date: Sat, 05 Aug 2000 05:59:31 GMT
From: jthornton@my-deja.com
Subject: Re: keys with duplicate values in dbm files
Message-Id: <8mgag3$gl$1@nnrp1.deja.com>
Try this...
Open your existing database into a hash, then repopulate it unless the
value has already been entered.
For example:
%seen = (); # declare this outside the before the loop.
foreach (somthing) {
$MAIN{"$url"} = $newvalue unless $seen{$url}++;
}
In article <398BA46D.DF723756@flashcom.net>,
lounge lizard <milosk@flashcom.net> wrote:
>
> --------------1E9C36A25E241131BCEA4B62
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Hi: I seem to have more than one value for several keys in my dbm
file
> - it seems to return the latest value entered in the file - I'm trying
> to delete the duplicates but am having problems - my script doesn't
> delete the right values
>
> basically I'm deleting from my dbm file %MAIN using
>
> delete ($MAIN{$URL}); - doesn't that delete all multiple occurrences
of
> the key? or can I use
>
> while (defined ($MAIN{$URL})) {
> delete ($MAIN{$URL});
> }
>
> then reentering the values:
>
> $MAIN{$URL} = $newvalue;
>
> I have about 1000 keys to delete - doing it one at a time works
> correctly but when I do a loop I run into problems even when I close
the
> dbm files on each loop. What am I doing wrong?
>
> Sorry if this is a really dumb Q - I'm relatively new to Perl,
>
> The relevant part of the script is below:
>
> for ($id=1000; $id<15500; $id++) {
> dbmopen (%ID, $keyIDdb, 0666) || die "can't open file\n";
> dbmopen (%MAIN, $keyMaindb, 0666) || die "can't open file\n";
> if (defined ($ID{$id})) {
> $URL = $ID{$id};
> $line = $MAIN{$URL};
> chomp ($line);
> @members_array=split(/\|/,$line);
> if ($id != $members_array[11]) { #if there's a duplicate
> $old_id = $members_array[11];
> $members_array[11]=$id;
> $newline = join ("\|",$members_array[0],$members_array[1]);
> delete ($MAIN{$URL}); #deletes all duplicate values
> from main db?
> }
> $MAIN{$URL} = $newline; #adds new value
> delete ($ID{$old_id}); #deletes duplicate value from
> id db
> $i +=1;
> }
> }
> }
>
> dbmclose (%MAIN);
> dbmclose (%ID);
> }
>
> --------------1E9C36A25E241131BCEA4B62
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>
> Hi: I seem to have more than one value for several keys in my
dbm
> file - it seems to return the latest value entered in the file - I'm
trying
> to delete the duplicates but am having problems - my script doesn't
delete
> the right values
> <p>basically I'm deleting from my dbm file %MAIN using
> <p>delete ($MAIN{$URL}); - doesn't that delete all multiple
occurrences
> of the key? or can I use
> <p>while (defined ($MAIN{$URL})) {
> <br> delete ($MAIN{$URL});
> <br> }
> <p>then reentering the values:
> <p>$MAIN{$URL} = $newvalue;
> <p>I have about 1000 keys to delete - doing it one at a time works
correctly
> but when I do a loop I run into problems even when I close the dbm
files
> on each loop. What am I doing wrong?
> <p>Sorry if this is a really dumb Q - I'm relatively new to Perl,
> <p>The relevant part of the script is below:
> <p>for ($id=1000; $id<15500; $id++) {
> <br> dbmopen (%ID, $keyIDdb, 0666) || die "can't open file\n";
> <br> dbmopen (%MAIN, $keyMaindb, 0666) || die "can't open
file\n";
> <br> if (defined ($ID{$id})) {
> <br> $URL = $ID{$id};
> <br> $line = $MAIN{$URL};
> <br> chomp ($line);
> <br> @members_array=split(/\|/,$line);
> <br> if ($id != $members_array[11])
{
> <b>#if there's a duplicate</b>
> <br> $old_id = $members_array[11];
> <br> $members_array[11]=$id;
> <br> $newline = join ("\|",$members_array
[0],$members_array[1]);
> <br> delete ($MAIN
{$URL}); &nbs
p;
> <b>#deletes all duplicate values from main db?</b>
> <br> }
> <br> $MAIN{$URL} =
$newline;
> <b>#adds new value</b>
> <br> delete ($ID
{$old_id}); &
nbsp;
> <b>#deletes duplicate value from id db</b>
> <br> $i +=1;
> <br> }
> <br> }
> <br> }
> <br>
> <br> dbmclose (%MAIN);
> <br> dbmclose (%ID);
> <br>}</html>
>
> --------------1E9C36A25E241131BCEA4B62--
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 05 Aug 2000 01:40:51 GMT
From: b_e_n_d_e_r@my-deja.com
Subject: LWP::Simple.pm
Message-Id: <8mfrb3$mri$1@nnrp1.deja.com>
Hi All
I'm looking for advice for using LWP::Simple.pm to retrieve the content
of a url. I've got the library (and all the supporting libraries)
installed and when I try to run my program I get a couple of errors.
The UserAgent.pm library says it can't find
auto/LWP/UserAgent/env_proxy.al and auto/LWP/UserAgent/_need_proxy.al.
Does anyone know what these files are and what they do? I've searched
around ww.perl.com and the CPAN sites but can't find any reference to
these files. Please help????
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 05 Aug 2000 03:55:56 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: My first module
Message-Id: <398b904c.217f$214@news.op.net>
Keywords: Pappas, forklift, septa, transoceanic
[Mailed and posted]
In article <8mf57h$7ik$1@nnrp1.deja.com>, <michaeljgardner@my-deja.com> wrote:
>What I'm trying to do is to eliminate copying the subroutine into each
>program that uses it. I'd like to be able to "use modulename", and have
>all the functionality of the subroutine available.
You should take a look at the Very Very Short Tutorial about Modules.
It has a super-short example of how to do that.
http://www.plover.com/~mjd/perl/Hello/
>At this point I'm still pretty weak on OO programming, so my best
>solution is one that doesn't require a lot of object oriented
>knowledge.
The tutorial is in two parts. The second part is about objects. The
first part is what you want. Ignore the second part.
------------------------------
Date: 04 Aug 2000 20:06:58 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: passing spaces in URL
Message-Id: <87r9845xe5.fsf@limey.hpcc.uh.edu>
>> On Fri, 04 Aug 2000 20:46:37 -0400,
>> Michael Ragsdale <mragsdal@utk.edu> said:
> 1. Stick with the POST method (I prefer passing named
> parameters) and somehow make the href link execute the
Well, actually that's irrelevant. Named parameters (I
assume you mean like tag=value) can be set up with either
method, although of course for large amounts of data POST
would be the way to go.
Not a perl issue.
> form submit command. I tried to find information on
You'd have to set up a FORM and you'd need some way to
submit, with either GET or POST. A simple link would
invoke GET.
That's outside the remit of perl though.
> my $x = 'I need help'; print
> $q->a({href=>"/this/that?something=$x"},"Test");
> comes out like: <a
> href="/this/that?something=I%20need%20help>Test</a>
use URI::Escape 'uri_escape';
print uri_escape("This has spaces in it"), "\n";
$ perldoc URI::Escape
and note that the CGI module has an escapeHTML() method
(which is usually pre-applied for you).
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Sat, 05 Aug 2000 04:58:30 GMT
From: jthornton@my-deja.com
Subject: Re: passing spaces in URL
Message-Id: <8mg6tl$u99$1@nnrp1.deja.com>
Why don't you just code your values with the seperator.
Instead of: my $x = 'I need help';
do: my $x = 'I%20need%20help';
or even better: my $x = 'I+need+help';
-James
In article <398B63ED.5387C72B@utk.edu>,
mragsdal@utk.edu wrote:
> Up until this point, I've called all of my scripts when the
> user clicks on the $q->submit(); button using the POST
> method. Now I'd like to call one when the user simply
> clicks on a href link. I figure I have two possible ways to
> do that, but not sure about either:
>
> 1. Stick with the POST method (I prefer passing named
> parameters) and somehow make the href link execute the form
> submit command. I tried to find information on this and
> found that href has an -OnClick() attribute, but it calls
> JavaScript, not CGI. If I went this route, how do I make
> the href link execute the form submit?
>
> 2. Use the GET method and simply put my parameter pairs in
> the URL of the href link. I tried this and had a problem.
> Some of my parameter strings have spaces and if they were
> not the last parameter passed, they lost all characters
> after the first space. I've seen URLs passed with some
> character string, perhaps %20, that represents a space
> before, but I've searched and searched and cannot find any
> information on replacing the spaces with this character
> string before I put the complete string in the URL. In
> other words, how do I make this:
>
> my $x = 'I need help';
> print $q->a({href=>"/this/that?something=$x"},"Test");
>
> comes out like:
> <a href="/this/that?something=I%20need%20help>Test</a>
>
> instead of:
> <a href="/this/that?something=I need help>Test</a>
>
> Again, I'd prefer to stick with the POST method, if there is
> any way to do that.
>
> -Mike
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 4 Aug 2000 21:52:12 -0400
From: "karamazov" <none>
Subject: problems with socket programming
Message-Id: <8mfrhc$o11$1@slb0.atl.mindspring.net>
hello, i am experimenting with perl and socket programming with it. i am
trying to code a simple tcp server that reads input from the client and
writes it to a file. but for some reason, my code isn't writing to the
file. i think the problem is with the FOR loop. i am a novice programmer
so any help would be appreciated. I've included my code below:
#!/usr/share/perl5
use Socket;
use FileHandle;
#Read main configuration file
open(SRM, "srm.conf") or die "can't open srm.conf: $!";
while($srmLine = <SRM>)
{
chop $srmLine;
@tempSrmArray = split /:/, $srmLine;
push @srmArray, $tempSrmArray[1];
}
$serverRoot = $srmArray[0];
$documentRoot = $serverRoot . $srmArray[1];
$cgiDirectory = $serverRoot . $srmArray[2];
close SRM;
#Read mime mapping file
open(MIME, "mime.conf") or die "can't open mime.conf: $!";
while($mimeLine = <MIME>)
{
chop $mimeLine;
@tempMimeArray = split /:/, $mimeLine;
$mimeHash{$tempMimeArray[0]} = $tempMimeArray[1];
}
close MIME;
#Setup server on network
$port = shift || 9156;
$proto = getprotobyname('tcp');
$sin = sockaddr_in($port, INADDR_ANY);
socket(Server, PF_INET, SOCK_STREAM, $proto) || die $!;
bind(Server, $sin) || die $!;
listen(Server, SOMAXCONN);
#Accept loop for client requests
for(; accept(Client,Server); close Client)
{
open(Incoming, ">Incoming.txt");
while($inLine = <STDIN>)
{
chop $inLine;
if(!$inLine)
{
last;
}
else
{
print Incoming "$inLine\n";
}
}
}
------------------------------
Date: Sat, 05 Aug 2000 04:34:19 +0200
From: indiziert <indiziert@unabomber.de>
Subject: reg expressions - protect html
Message-Id: <398B7D2A.D155820B@unabomber.de>
hi
hm well
i wrote a script that replaces certain characters by numbers e.g Hello -
H3ll0
i was figuring out how to translate html pages with it. but the script
translated even the html tags, so that there were no html code.
if i translate a html page you can see:
<H7M1> instead of <HTML> because a T is translated to 7 and an L to 1.
so how can i protect html tags from being translated ?
i need someting that keeps html tags but still changes characters
thanx in advance
indiziert
------------------------------
Date: 05 Aug 2000 05:03:10 GMT
From: abigail@foad.org (Abigail)
Subject: Re: reg expressions - protect html
Message-Id: <slrn8on7vt.st1.abigail@alexandra.foad.org>
indiziert (indiziert@unabomber.de) wrote on MMDXXXI September MCMXCIII in
<URL:news:398B7D2A.D155820B@unabomber.de>:
!! hi
!!
!! hm well
!!
!! i wrote a script that replaces certain characters by numbers e.g Hello -
!! H3ll0
!!
!! i was figuring out how to translate html pages with it. but the script
!! translated even the html tags, so that there were no html code.
!! if i translate a html page you can see:
!! <H7M1> instead of <HTML> because a T is translated to 7 and an L to 1.
!! so how can i protect html tags from being translated ?
By parsing the HTML, and only apply the translation on the text parts.
There are modules on CPAN that can assist you.
Abigail
--
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${${@}}[$#{@{${@}}}]'
------------------------------
Date: Fri, 04 Aug 2000 22:32:18 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: reg expressions - protect html
Message-Id: <398BA6E2.DED16BDC@la.znet.com>
indiziert wrote:
> i wrote a script that replaces certain characters by numbers e.g Hello -
> H3ll0
> i was figuring out how to translate html pages with it. but the script
> translated even the html tags, so that there were no html code.
> if i translate a html page you can see:
> <H7M1> instead of <HTML> because a T is translated to 7 and an L to 1.
> so how can i protect html tags from being translated ?
> i need someting that keeps html tags but still changes characters
K-rAÐ k3WL dUdz!
Ðo it Godzilla §chizo §tyle!
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
my ($input) = "
With A Purposeful <HTML> Grimace And A Terrible Sound
She Pulls The Spitting High Tension Wires Down
Helpless People On A Subway Train
Scream <HTML> Bug-eyed As She Looks In On Them
She Picks Up A Bus And She Throws <HTML> It Back Down
As She Wades Through The Buildings Toward The Center Of Town
Oh No, They Say She's Got To Go Go Go Godzilla
<HTML> Oh No, There Goes Tokyo Go Go Godzilla
History Shows Again And Again <HTML>
How Nature Points Up The Folly Of Men";
my (@Array_Input) = split (/ /, $input);
my (@Kewl_Dudz) = ("A:Å", "B:ß", "C:Ç", "D:Ð", "L:£",
"N:Ñ", "O:Ö", "S:§");
foreach $input_line (@Array_Input)
{
foreach $kewl_dudz (@Kewl_Dudz)
{
($key, $value) = split (/:/, $kewl_dudz);
if ($input_line =~ /<|\n/)
{ next; }
else
{ $input_line =~ s/$key/$value/; }
}
$output = join (" ", $output, $input_line);
}
print $output;
exit;
PRINTED RESULTS:
________________
With Å Purposeful <HTML> Grimace Ånd Å Terrible Sound
She Pulls The §pitting High Tension Wires Down
Helpless People Ön Å §ubway Train
Scream <HTML> ßug-eyed Ås §he £ooks In Ön Them
She Picks Up Å ßus Ånd §he Throws <HTML> It ßack Down
As §he Wades Through The ßuildings Toward The Çenter Öf Town
Oh Ño, They §ay §he's Got To Go Go Go Godzilla
<HTML> Öh Ño, There Goes Tokyo Go Go Godzilla
History §hows Ågain Ånd Ågain <HTML>
How Ñature Points Up The Folly Öf Men
Godzilla!
--
use LWP::Simple;
$g = get
("http://3483852801/%7e%63%61ll%67i%72l/%76i%64%65%67%6f%64z%2e%68%74%6dl");
$g =~ s/(<([^>]+)>)|\n|GODZILLA|Blue Oyster Cult//g;
$g =~ s/([a-z])([A-Z])/$1\n$2/g; $g =~ s/(He )/S\l$1/g;
$g =~ s/H(e')/Sh$1/; print ${\substr ($g, 9, 429)}; exit;
------------------------------
Date: Fri, 04 Aug 2000 22:53:18 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: reg expressions - protect html
Message-Id: <398BABCE.2E31B2BA@la.znet.com>
"Godzilla!" wrote:
> indiziert wrote:
> > i wrote a script that replaces certain characters by numbers e.g Hello
> K-rAÐ k3WL dUdz!
> Ðo it Godzilla §chizo §tyle!
Oh! Oh! Just came to me, a split on spaces
will mess up your html which include spaces!
Oh! Oh!
* goes into a tizzy *
Give me a bit. I have a schizo cure for this!
Godzilla!
------------------------------
Date: 05 Aug 2000 08:52:10 +0200
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: reg expressions - protect html
Message-Id: <m33dkk2o9x.fsf@eik.g.aas.no>
indiziert <indiziert@unabomber.de> writes:
> i wrote a script that replaces certain characters by numbers e.g Hello -
> H3ll0
>
> i was figuring out how to translate html pages with it. but the script
> translated even the html tags, so that there were no html code.
> if i translate a html page you can see:
> <H7M1> instead of <HTML> because a T is translated to 7 and an L to 1.
> so how can i protect html tags from being translated ?
>
> i need someting that keeps html tags but still changes characters
The HTML::Parser module comes with a sample script (eg/htextsub) that
goes like this:
--------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my $code = shift || usage();
$code = 'sub edit_print { local $_ = shift; ' . $code . '; print }';
#print $code;
eval $code;
die $@ if $@;
use HTML::Parser 3.05;
my $p = HTML::Parser->new(unbroken_text => 1,
default_h => [ sub { print @_; }, "text" ],
text_h => [ \&edit_print, "text" ],
);
my $file = shift || usage();
$p->parse_file($file) || die "Can't open file $file: $!\n";
sub usage
{
my $progname = $0;
$progname =~ s,^.*/,,;
die "Usage: $progname <perlexpr> <filename>\n";
--------------------------------------------------------------------
With it you should be able to do your replacements with something
like:
$ htextsub 'tr/eoTL/3071/' file.html
--
Gisle Aas
------------------------------
Date: Sat, 05 Aug 2000 01:49:43 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Regexp problem - Stripping HTML
Message-Id: <398d713f.2926310@news.newsguy.com>
I wrote:
>abigail@foad.org (Abigail) wrote:
>>Jeff Yoak (jeff@yoak.com) wrote on MMDXXVIII September MCMXCIII in
>><URL:news:8m9lo904qv@news1.newsguy.com>:
>><>
>><> Hmmm.... OK. I take it back. I'm not sure what's involved in parsing
>><> non-standard tags with those tools. If you are sure that the tag will
>><> start with '<?php' and will not contain '?>' until the termination of the
>><> tag (I don't know PHP, but this seems safe) , you can use:
>><>
>><> $x =~ s/<\?php.*?\?>//g;
>>
>>No, that requires more than the conditions you stated. It also requires
>>that every <?php substring starts a tag.
>
>I'm hesitant to disagree with Abigail about a regex, but it
>seems to me that if there's a <?php substring within a tag, the
>regex will already have matched the earlier <?php at the
>beginning of the tag. Nongreediness only works at the end, not
>the beginning, of the .*?.
And I didn't hesitate long enough. I realize now the situation
Abigail was referring to. The additional requirement is
actually that every <?php substring either start a tag or be
inside a tag. Something like <!-- <?php --> or <img src="a.gif"
alt="<?php"> will cause it to fail. Still, it seems likely that
the condition would apply in the original poster's situation.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Sat, 05 Aug 2000 01:39:29 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Regexp problem - Stripping HTML
Message-Id: <398b6da7.2006436@news.newsguy.com>
abigail@foad.org (Abigail) wrote:
>Jeff Yoak (jeff@yoak.com) wrote on MMDXXVIII September MCMXCIII in
><URL:news:8m9lo904qv@news1.newsguy.com>:
><>
><> Hmmm.... OK. I take it back. I'm not sure what's involved in parsing
><> non-standard tags with those tools. If you are sure that the tag will
><> start with '<?php' and will not contain '?>' until the termination of the
><> tag (I don't know PHP, but this seems safe) , you can use:
><>
><> $x =~ s/<\?php.*?\?>//g;
>
>No, that requires more than the conditions you stated. It also requires
>that every <?php substring starts a tag.
I'm hesitant to disagree with Abigail about a regex, but it
seems to me that if there's a <?php substring within a tag, the
regex will already have matched the earlier <?php at the
beginning of the tag. Nongreediness only works at the end, not
the beginning, of the .*?.
Jeff's regex does require another condition, though, which might
be important: the <?php ... ?> can't extend over more than one
line. With the /s modifier, though, it seems like it should be
okay:
#! perl -w
$x = <<EOT;
<?php <?php <?php to be <?php deleted ?> should stay <?php
more stuff to <?php delete ?> and more to stay <?php ?>
EOT
$x =~ s/<\?php.*?\?>//gs;
print "($x)\n";
Output:
( should stay and more to stay
)
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 05 Aug 2000 04:45:38 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Regexp problem - Stripping HTML
Message-Id: <slrn8on6v1.st1.abigail@alexandra.foad.org>
Keith Calvert Ivey (kcivey@cpcug.org) wrote on MMDXXXI September MCMXCIII
in <URL:news:398b6da7.2006436@news.newsguy.com>:
??
?? I'm hesitant to disagree with Abigail about a regex, but it
?? seems to me that if there's a <?php substring within a tag, the
?? regex will already have matched the earlier <?php at the
?? beginning of the tag. Nongreediness only works at the end, not
?? the beginning, of the .*?.
So, <TAG ATR = '<?php'>, <!-- <?php --> and <![CDATA [ <?php ]]> are
garenteed not present in the document? What other convenient assumptions
can be made?
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: Sat, 05 Aug 2000 05:26:54 GMT
From: "News-Server" <gwcyw@yahoo.com>
Subject: Secured login form submission
Message-Id: <yANi5.2045$Ln4.20979@news-server.bigpond.net.au>
I have a online service provider which I can login from the web and download
some data.
I wanted to automate the process using perl. It's a secured login requires
the browser to support 128 bit encryption.
From Internet Exploer I can use the following as URL to login:
"http://www.myprovider.com/cgi-bin/login.pl?client_no=my_client_no&pin=my_pl
ain_text_pin".
Then use the following as URL to get data:
"http://www.myprovider.com/cgi-bin/getdata.pl?datadate=01/01/00&datacode=the
_code"
I downloaded some modules from CPAN and tried the following code but didn't
succeed.
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
my $req = POST 'http://www.myprovidercom/cgi-bin/123.pl',
[ client_no => 'my_client_no', pin => 'my_pin' ];
$content = $ua->request($req)->as_string;
print $content; # for debugging purpose
$req = POST 'http://www.myprovidercom/cgi-bin/getdata.pl',
[ data_date => '01/01/00', data_code => 'abc' ];
$content = $ua->request($req)->as_string;
print $content;
It appeared that the login didn't succeed. I viewed my provider's login page
source from IE, there's a section contains something like:
action="http://www.myprovider.com/cgi-bin/login.pl"
method=POST
name=client_no, type=text,
name=pin, type=password
What can I do in perl to automate the login? Was it the 128 bit encryption
causing problems?
Thanks for any help,
CYW
------------------------------
Date: Sat, 05 Aug 2000 02:08:50 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: semijoin() - a better way?
Message-Id: <398f7615.4164805@news.newsguy.com>
SPAM+indigo@dimensional.com (Tim) wrote:
>kcivey@cpcug.org (Keith Calvert Ivey) wrote
>
>>anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>>
>>>Well without the frills about negative $itemcount, the basic function
>>>is
>>>
>>>push @newlist, join $jstr, splice( @oldlist, 0, $itemcount) while
>>>@oldlist;
>>
>>And with a negative $itemcount, it's
>>
>> unshift @newlist, join $jstr, splice( @oldlist,
>> (-$itemcount > @oldlist ? 0 : $itemcount ), -$itemcount)
>> while @oldlist;
>>
>Careful...both of those solutions eat the original list.
Yes, but as Anno said, those are just the basic functions. When
you make it into a subroutine you would copy the arguments first
as usual.
>my @old = qw(a b c d e f g h i j k l m);
>my @new;
>my $j = '+';
>my $i = 5;
>
>@new = ((map { join $j, @old[$_ * $i .. ($_ + 1) * $i - 1] }
> 0 .. @old / $i - 1),
> @old[-(@old % $i) .. -1]);
>
>print "$_\n" for @new;
>
>----
>
>a+b+c+d+e
>f+g+h+i+j
>k
>l
>m
The way Anno and I interpreted the specifications, that should
end in "k+l+m", so you'd need another join before the second
list slice.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 5 Aug 2000 04:18:52 GMT
From: jgamble@ripco.com (John M. Gamble)
Subject: Re: semijoin() - a better way?
Message-Id: <8mg4jc$5ff$1@gail.ripco.com>
In article <398f7615.4164805@news.newsguy.com>,
Keith Calvert Ivey <kcivey@cpcug.org> wrote:
>SPAM+indigo@dimensional.com (Tim) wrote:
>>kcivey@cpcug.org (Keith Calvert Ivey) wrote
>>
>>>anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>>>
>>>>Well without the frills about negative $itemcount, the basic function
>>>>is
>>>>
>>>>push @newlist, join $jstr, splice( @oldlist, 0, $itemcount) while
>>>>@oldlist;
>>>
>>>And with a negative $itemcount, it's
>>>
>>> unshift @newlist, join $jstr, splice( @oldlist,
>>> (-$itemcount > @oldlist ? 0 : $itemcount ), -$itemcount)
>>> while @oldlist;
>>>
>>Careful...both of those solutions eat the original list.
>
>Yes, but as Anno said, those are just the basic functions. When
>you make it into a subroutine you would copy the arguments first
>as usual.
>
>>my @old = qw(a b c d e f g h i j k l m);
>>my @new;
>>my $j = '+';
>>my $i = 5;
>>
>>@new = ((map { join $j, @old[$_ * $i .. ($_ + 1) * $i - 1] }
>> 0 .. @old / $i - 1),
>> @old[-(@old % $i) .. -1]);
>>
>>print "$_\n" for @new;
>>
>>----
>>
>>a+b+c+d+e
>>f+g+h+i+j
>>k
>>l
>>m
>
>The way Anno and I interpreted the specifications, that should
>end in "k+l+m", so you'd need another join before the second
>list slice.
>
You are absolutely right, the remaining elements form a short list
at the end (or, if negative increment, a short list forms at the
beginning before the rest get joined)
You guys are all great, thank you for your suggestions - i now have
somthing to work with (i never was much of a map operator user, now
i have more of an incentive).
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
--
Pursuant to US Code, Title 47, Chapter 5, Subchapter II, '227,
any and all unsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500
US. E-mailing denotes acceptance of these terms.
------------------------------
Date: 5 Aug 2000 02:41:12 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: String to Integer -- but oct/hex not converted!
Message-Id: <8mfus8$6bb3g$2@ID-24002.news.cis.dfn.de>
hi,
Juha Laiho <Juha.Laiho@iki.fi> wrote:
> oderus54@my-deja.com said:
>>Is there a function in perl that changes a string to an integer, for
>>example.
>>
>>$blah = "123456";
>># Now i want $num = 123456
> As has been discussed, '$num=0+$blah;' can be used, but warily. Here's
> something I noticed today while just fooling around with the conversion.
> ~$ perl -e 'print 0+"0755","\n",0+0755,"\n";'
> 755
> 493
> .. so the quotes do make a difference. Beware.
but if you have a string and extract the numbers out of it,
you won't have any problems. 0755 is interpreted
as an octal number, so it's 493 before 0 is added.
if you do $num = 0+$input and input comes out
of a file or whatever, it is always treated as a string.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
Date: 5 Aug 2000 05:35:57 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Subclassing an opaque class
Message-Id: <8mg93t$cvd$1@towncrier.cc.monash.edu.au>
Ilmari Karonen <iltzu@sci.invalid> writes:
>However, this brought up a tricky issue: When perl can't find a method
>in a class or any of its superclasses, it looks for an AUTOLOAD sub in
>any of those classes. This works just fine if only one of the classes
>uses AUTOLOAD, but even after grepping the PODs I still haven't been
>able to find a way to continue the search if the first AUTOLOAD found
>can't handle the request.
shift->SUPER::AUTOLOAD(@_);
but that will only resume looking upwards from the current node.
There is no way to restart the full recursive look-up.
At least, not without some *seriously* arcane tricks with local typeglobs.
Damian
PS: I'll be proposing this problem be fixed in Perl 6, but that's not
much help to you now.
------------------------------
Date: 5 Aug 2000 05:26:19 GMT
From: homer.simpson@springfield.nul (Homer Simpson)
Subject: Re: Tk module for Windows NT
Message-Id: <8mg8hr$3or$0@216.39.131.175>
In article <398ABC2A.52DB2704@patriot.net>, H C <carvdawg@patriot.net> wrote:
>ppm install Tk
>
>gopal_bhat@my-deja.com wrote:
>
>> Hi,
>> I got Active-Perl(5.006) for WinNT and I wanted to install Tk module
>> (perl -e 'use Tk' should work first). Please post a reply to this
>> posting if any of you know a place on the net, where I can download
>> compiled Tk module for Win NT.
>> thanks
>>
>> Sent via Deja.com http://www.deja.com/
>> Before you buy.
>
This is what I get when I try:
C:\>ppm install Tk
junk after document element at line 1, column 63, byte 63 at
C:/Perl/site/lib/XM
L/Parser.pm line 168
C:\>
------------------------------
Date: 4 Aug 2000 22:33:49 -0700
From: gerg@ncal.verio.com (Greg Andrews)
Subject: Re: very cool routine
Message-Id: <8mg8vt$7nt$1@ncal.verio.com>
>
>> second, the reason for the speed difference is partly the
>> stuff you said, but mainly because the builtin functions
>> are written in C as you will read on a previous post.
>
>> C is fast.
>> PERL is comparably extremely slow.
>> Copiler VS Interpreter
>
>(snipped)
>
>
>Ummm... Mr. Bank, I really must object. If you employ
>good logic, cite truisms, state facts and debate issues
>based on rational thinking, these people, well... their
>brains will explode.
>
It's apparent that this piece of advice was based on
first-hand experience.
-Greg
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
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 3921
**************************************