[19317] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1512 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 13 18:10:41 2001

Date: Mon, 13 Aug 2001 15:10:17 -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: <997740617-v10-i1512@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 13 Aug 2001     Volume: 10 Number: 1512

Today's topics:
        Search Engine Matching Problem (Stearnsie)
    Re: Search Engine Matching Problem <Tassilo.Parseval@post.rwth-aachen.de>
    Re: setting a cookie <gnarinn@hotmail.com>
    Re: setting a cookie <jerseycat10@yahoo.com>
        Socket Question <skpurcell@hotmail.com>
    Re: Statement modifiers?? ctcgag@hotmail.com
        Uh Oh: URL Encode <jtjohnston@courrier.usherb.ca>
    Re: Uh Oh: URL Encode <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Uh Oh: URL Encode <comdog@panix.com>
    Re: Uh Oh: URL Encode <bart.lateur@skynet.be>
    Re: Uh Oh: URL Encode <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Uh Oh: URL Encode <jtjohnston@courrier.usherb.ca>
    Re: Uh Oh: URL Encode <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Uploading a file via a browser w/out using CGI.pm <wizard@psychodad.com>
    Re: URL Encode <jtjohnston@courrier.usherb.ca>
    Re: URL Encode <Tassilo.Parseval@post.rwth-aachen.de>
    Re: URL Encode <jtjohnston@courrier.usherb.ca>
    Re: URL Encode <Tassilo.Parseval@post.rwth-aachen.de>
    Re: validate IP address (John Stanley)
        VIER/NEUN problem (Greg Bacon)
        Way to do database read to disk instead of memory? (Jane B.)
    Re: whither tchrist? <pne-news-20010813@newton.digitalspace.net>
    Re: whither tchrist? <dan@tuatha.sidhe.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 13 Aug 2001 12:58:02 -0700
From: ccstearns@ucsd.edu (Stearnsie)
Subject: Search Engine Matching Problem
Message-Id: <ac757ead.0108131158.760c4398@posting.google.com>

OK, I really have no idea how to use Perl programming, but I managed
to find a code on the internet which I modified and used for my own
search engine, but my problem is that when I do the search... say for
an author with a year, it does not search the database for those
fields together, but rather it prints All the results with that
author, and then all the results with that year.
So here is my code, and it may be something small that I have to
change I'm thinking. But I would be very thankful for any help from
anyone.
Thanks.



#!c:\unzipped\indigoperl-5_6\bin\perl
#
#
#
# This is the cgi script to run an address manager form.
#
# requires cgi-lib.pl
require 'cgi-lib.pl';

# grab values passed from form:
&ReadParse(*in);

print "Content-type: text/html\n\n";

# print the top part of the response
print "<HTML><HEAD><TITLE>Search Results</TITLE></HEAD>\n";
print "<FONT COLOR=#00008B><Center><H1>Literature Database Search
Engine</H1></Center></FONT>\n";

# read and parse data file
$data="address.data";

open(DATA,"$data") || die "Can't open $data: $!\n</BODY></HTML>\n";
while(<DATA>) {
	chop;	# delete trailing \n
	if (/^\s*$/) {
		# break between records
		if ($match) {
			# if anything matched, print the whole record
			&printrecord($record);
			$nrecords_matched++;
		}
		undef $match;
		undef $record;
		next;
	}
	# tag: value
	($tag,$val) = split(/:/,$_,2);
	if ($tag =~ /^Author1/i) {
		$match++ if( $in{'Author'} && $val =~ /\b$in{'Author'}\b/i) ;
		$record = "\n<BR>Author: $val" if ($val);
		next;
	}
	if ($tag =~ /^Author2/i) {
		$match++ if( $in{'Author'} && $val =~ /\b$in{'Author'}\b/i) ;
		$record .= "\n<BR>Author: $val" if ($val);
		next;
	}
	if ($tag =~ /^Author3/i) {
		$match++ if( $in{'Author'} && $val =~ /\b$in{'Author'}\b/i) ;
		$record .= "\n<BR>Author: $val" if ($val);
		next;
	}
	if ($tag =~ /^Author4/i) {
		$match++ if( $in{'Author'} && $val =~ /\b$in{'Author'}\b/i) ;
		$record .= "\n<BR>Author: $val" if ($val);
		next;
	}
	if ($tag =~ /^Year/i) {
		$match++ if( $in{'Year'} && $val =~ /\b$in{'Year'}\b/i) ;
		$record .= "\n<BR>Year: $val" if ($val);
		next;
	}
	if ($tag =~ /Title/i) {
		$match++ if( $in{'Title'} && $val =~ /\b$in{'Title'}\b/i) ;
		$record .= "\n<BR>Title: $val" if ($val);
		next;
	}
	if ($tag =~ /Journal/i) {
		$match++ if( $in{'Journal'} && $val =~ /\b$in{'Journal'}\b/i) ;
		$record .= "\n<BR>Journal: $val" if ($val);
		next;
	}
	if ($tag =~ /Paper/i) {
		$match++ if( $in{'Paper'} && $val =~ /\b$in{'Paper'}\b/i) ;
		$record .= "\n<BR>Paper: $val" if ($val);
		next;
	}
	if ($tag =~ /Conference/i) {
		$match++ if( $in{'Conference'} && $val =~ /\b$in{'Conference'}\b/i)
;
		$record .= "\n<BR>Conference: $val" if ($val);
		next;
	}
		if ($tag =~ /Volume/i) {
		$match++ if( $in{'Volume'} && $val =~ /\b$in{'Volume'}\b/i) ;
		$record .= "\n<BR>Volume: $val" if ($val);
		next;
	}
	if ($tag =~ /Issue/i) {
		$match++ if( $in{'Issue'} && $val =~ /\b$in{'Issue'}\b/i) ;
		$record .= "\n<BR>Issue: $val" if ($val);
		next;
	}
		if ($tag =~ /Page/i) {
		$match++ if( $in{'Page'} && $val =~ /\b$in{'Page'}\b/i) ;
		$record .= "\n<BR>Pages: $val" if ($val);
		next;
	}
			if ($tag =~ /Organization/i) {
		$match++ if( $in{'Organization'} && $val =~
/\b$in{'Organization'}\b/i) ;
		$record .= "\n<BR>Organization: $val" if ($val);
		next;
	}
			if ($tag =~ /Keywords/i) {
		$match++ if( $in{'Keywords'} && $val =~ /\b$in{'Keywords'}\b/i) ;
		$record .= "\n<BR>$val" if ($val);
		next;
	}
	# anything else
	$record .= $_;
}
close DATA;

if (! defined $nrecords_matched)
{ print "<H2>No Matches</H2>\n"; }

print "</BODY></HTML>\n";
exit;

sub printrecord {
	local($buf) = @_;
	print "<P>\n$buf<P>\n";
}


------------------------------

Date: Mon, 13 Aug 2001 22:12:03 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Search Engine Matching Problem
Message-Id: <3B783493.9030806@post.rwth-aachen.de>

Stearnsie wrote:
> OK, I really have no idea how to use Perl programming, but I managed
> to find a code on the internet which I modified and used for my own
> search engine, but my problem is that when I do the search... say for
> an author with a year, it does not search the database for those
> fields together, but rather it prints All the results with that
> author, and then all the results with that year.
> So here is my code, and it may be something small that I have to
> change I'm thinking. But I would be very thankful for any help from
> anyone.
> Thanks.

[snipped nasty code]

Honestly, this is extremely ugly code....as un-Perlish as it may 
possibley get and written with the obvious purpose of making subtle 
changes in behavious hard to achieve.
In first instance, I'd recommend to you to look out for a more friendly 
base for your search engine. People here will be willing to help you 
adjusting it to your needs...but not this code. It's a pain.

Tassilo




-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Mon, 13 Aug 2001 18:18:52 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: setting a cookie
Message-Id: <997726732.716402658261359.gnarinn@hotmail.com>

In article <9l6vpr$p71$1@bob.news.rcn.net>, AJ M <jerseycat10@yahoo.com> wrote:
>Hello, I seem to have no trouble( i think) retrieving cookie(s).  I retrieve
>it like this:
>
>  %cookies = fetch CGI::Cookie;
>  $status = defined $cookies{'validity'} ? $cookies{'validity'}->value :
>undef;
>
>(THANKS TO Ilya Martynov )
>
>However, I cannot seem to figure out how to set it properly, it always comes
>up as being empty.
>

try using the CGI module to output the cookie.
there can be zillions things wrong with your hand built cookie header.
when you got it working, then if you absolutely hate use the CGI.pm, you can
change back to your code, one piece at a time, and find out where it breaks

gnari



------------------------------

Date: Mon, 13 Aug 2001 17:26:27 -0400
From: "AJ M" <jerseycat10@yahoo.com>
Subject: Re: setting a cookie
Message-Id: <9l9gta$93k$1@bob.news.rcn.net>

thanks for the knowledge everyone, I have used the CGI.pm module to solve
the problems.  I am also referencing the book written by its author.
Thanks.

Aj


AJ M <jerseycat10@yahoo.com> wrote in message
news:9l6vpr$p71$1@bob.news.rcn.net...
> Hello, I seem to have no trouble( i think) retrieving cookie(s).  I
retrieve
> it like this:
>
>   %cookies = fetch CGI::Cookie;
>   $status = defined $cookies{'validity'} ? $cookies{'validity'}->value :
> undef;
>
> (THANKS TO Ilya Martynov )
>
> However, I cannot seem to figure out how to set it properly, it always
comes
> up as being empty.
>
> I only need to be able to set this one cookie (with a timeout when browser
> it closed).
>
> I know that it is only like 2-3 lines of code, but I cannot figure it out
or
> find it anywhere!
>
> Thanks for any help!
>
> AJ
>
>
>
>
>




------------------------------

Date: Mon, 13 Aug 2001 16:01:37 -0500
From: "spurcell" <skpurcell@hotmail.com>
Subject: Socket Question
Message-Id: <3b78412b$0$141@wodc7nh6.news.uu.net>

I have a piece of server software that talks sockets. I cannot use
IO::Socket because of a mod_perl/apache bug. So I need to use the most
simplest form I can in order to send the server a question, and get back a
response. The following code comes from the camel 2 pp 604, but I cannot
seem to get the data read back. I do see that I sent the question (data) to
the socket, (tailing the log file shows I am chatting), but I cannot seem to
get the response, it just hangs ...
Does anyone have any ideas why?


thanks
Scott

#! perl

use Socket;
$socketdebug    = 1;
$mbport         = '9000';
$mbhost         = 'xxx.238.162.xxx';

socket(HANDLE, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
                                #
# build the address of the remote machine
$internet_addr = inet_aton($mbhost) or die("Couldn't convert $mbhost to an
internet addr. $!\n");
print "$internet_addr is internetaddr\n";
$paddr = sockaddr_in($mbport, $internet_addr);
print "$paddr is paddr\n";
connect(HANDLE, $paddr) or die ("Cannot connect to $mbhost:$mbport");


my $msgid = int(rand(1000));
my $message = "$msgid\tUSERLOGIN\tVBO\t99999xxxxxx999999xxxxxx";
my $msgsize = length($message);
print "$msgsize\n$message\n";
print HANDLE "\%BEGIN\t$msgsize\n$message\n";

while (read HANDLE, $buf, 16384) {
    print "$buf";
}


1;





------------------------------

Date: 13 Aug 2001 19:56:53 GMT
From: ctcgag@hotmail.com
Subject: Re: Statement modifiers??
Message-Id: <20010813155653.484$A0@newsreader.com>

Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "CCG" == Carlos C Gonzalez <miscellaneousemail@yahoo.com> writes:
>   CCG> In article <20010812200902.398$NG@newsreader.com>,
>   CCG> I believe the above statement is as good as one could hope to find
>   in a CCG> single sentence explaining what a statement modifier is and
>   how to use CCG> one.

Thank you.

 ...

> perl offers these alternates not for academic purity but for better
> communication between the coder and the readers of that code. that is a
> very important point that is rarely discussed.

And one I wish my predecessor had followed.  Or perhaps he thinks he
did, but his ideas of what is intuitive and mine are different.

Usually I use statement modifiers in places where I think it is unlikely
that future maintainence will occur, or where such maintence will be in the
test rather than the statements.

I also tend to put more whitespace in
regions I consider volatile, and less in regions I consider stable.

What's more, always add "or die" to the ends of things that can fail in
general, even if they can't conceivably fail in the local logic.

m/Foo(.*)Bar/ or die;
do_something($1);

Yes, even if you already made sure that Foo and Bar are there and in
order, still add the or die.


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                    Usenet Newsgroup Service


------------------------------

Date: Mon, 13 Aug 2001 20:26:47 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Uh Oh: URL Encode
Message-Id: <3B783631.7167DC27@courrier.usherb.ca>

>     use URI::Escape;

use URI::Escape;

>$message = "what a =nice\"\@$%?*() day it's& going to be?.!";
>$message = uri_escape($message);
>print "$message";

The problem is that it still doesn't escape the characters: ,.?!

what%20a%20=nice%22@0?*()%20day%20it's&%20going%20to%20be?.!

My input could read like:

$in('message') = "what a =nice\"\@$%?*() day it's& going to be?.!";

and I pass it through:

http://ww.aa.com/doit.cgi?$in('message')&action=complete

? & = become illiegal characters for what I push through <stdn>

It will read like:

http://ww.aa.com/doit.cgi?what%20a%20=nice%22@0?*()%20day%20it's&%20going%20to%20be?.!&action=complete

Is there another way? I could do this:

use URI::Escape;

$message = "what a =nice\"\@$%?*() day it's& going to be?.!";
$message = uri_escape($message);
$in('message') =~ s/!/%21/g;
$in('message') =~ s/?/%3F/g;
$in('message') =~ s/;/%3B/g;
$in('message') =~ s/:/%3A/g;

But that defeats the purpose of finding one, quick, clean method, no?

Thanks,

John



------------------------------

Date: Mon, 13 Aug 2001 22:39:12 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B783AF0.3000403@post.rwth-aachen.de>

jtjohnston wrote:

> The problem is that it still doesn't escape the characters: ,.?!
> 
> what%20a%20=nice%22@0?*()%20day%20it's&%20going%20to%20be?.!
> 
> My input could read like:
> 
> $in('message') = "what a =nice\"\@$%?*() day it's& going to be?.!";
> 
> and I pass it through:
> 
> http://ww.aa.com/doit.cgi?$in('message')&action=complete
> 
> ? & = become illiegal characters for what I push through <stdn>
> 
> It will read like:
> 
> http://ww.aa.com/doit.cgi?what%20a%20=nice%22@0?*()%20day%20it's&%20going%20to%20be?.!&action=complete
> 
> Is there another way? I could do this:
> 
> use URI::Escape;
> 
> $message = "what a =nice\"\@$%?*() day it's& going to be?.!";
> $message = uri_escape($message);
> $in('message') =~ s/!/%21/g;

Wait a min! What is $in('message') supposed to be? This is certainly no 
valid Perl. Perhaps you should take care that your script starts thus 
(-T for tainted since this is CGI):

#! perl -wT
use strict;

But even without that, this should have earned you a syntax error.

> $in('message') =~ s/?/%3F/g;

Secondly, this is not going to work. '?' is a special character in a 
regex-pattern, so it should read "$in =~ s/\?/%3F/g;"

> But that defeats the purpose of finding one, quick, clean method, no?

Yes, but I have my doubts that it is a problem with URI::un_escape. Can 
you show us your original code?

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Mon, 13 Aug 2001 16:51:17 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Uh Oh: URL Encode
Message-Id: <comdog-C550C3.16511713082001@news.panix.com>

In article <3B783631.7167DC27@courrier.usherb.ca>, jtjohnston 
<jtjohnston@courrier.usherb.ca> wrote:

> >$message = "what a =nice\"\@$%?*() day it's& going to be?.!";
> >$message = uri_escape($message);
> >print "$message";
> 
> The problem is that it still doesn't escape the characters: ,.?!

did you read the URI::Escape documentation?  the answer to this
isn't hidden or vague.

-- 
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



------------------------------

Date: Mon, 13 Aug 2001 20:55:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Uh Oh: URL Encode
Message-Id: <bafgntkd4fv5pntj7k9j9dqducdtl453h7@4ax.com>

jtjohnston wrote:

>>     use URI::Escape;
>>$message = "what a =nice\"\@$%?*() day it's& going to be?.!";
>>$message = uri_escape($message);
>>print "$message";
>
>The problem is that it still doesn't escape the characters: ,.?!
>
>what%20a%20=nice%22@0?*()%20day%20it's&%20going%20to%20be?.!

It's worse than that.

	use URI::Escape;
	print uri_escape('a=b&c=d');
-->
	a=b&c=d

It DOES NOT escape the most dangerous characters "=" and "&". It's a
know bug, or feature, depending on what side you're on. Lincoln Stein
describes it in his book "Network Programming with Perl", in chapter 9.

It's as if a HTML_escape() function wouldn't escape "<" and "&". Bloody
Hell. It's a good enough reason for me never ever to use this module.

As an alternative, CGI::Minimal contains a method without this quirk.
BTW the bulk of the code is just 1 line.

	use CGI::Minimal;
	print CGI::Minimal->url_encode('a=b&c=d');
-->
	a%3db%26c%3dd

-- 
	Bart.


------------------------------

Date: Mon, 13 Aug 2001 23:00:06 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B783FD6.9000503@post.rwth-aachen.de>

Bart Lateur wrote:
> jtjohnston wrote:
> 
> 
>>>    use URI::Escape;
>>>$message = "what a =nice\"\@$%?*() day it's& going to be?.!";
>>>$message = uri_escape($message);
>>>print "$message";
>>>
>>The problem is that it still doesn't escape the characters: ,.?!
>>
>>what%20a%20=nice%22@0?*()%20day%20it's&%20going%20to%20be?.!
>>
> 
> It's worse than that.
> 
> 	use URI::Escape;
> 	print uri_escape('a=b&c=d');
> -->
> 	a=b&c=d
> 
> It DOES NOT escape the most dangerous characters "=" and "&". It's a
> know bug, or feature, depending on what side you're on. Lincoln Stein
> describes it in his book "Network Programming with Perl", in chapter 9.

Well, rather a sort of unpleasant feature. But uri_escape takes a second 
argument. It is a character-class which overrides the characters usually 
escaped. So with that, one could force uri_escape to also escape & and =.

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Mon, 13 Aug 2001 21:06:42 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B783F8A.A825550B@courrier.usherb.ca>

> Yes, but I have my doubts that it is a problem with URI::un_escape. Can
> you show us your original code?

I haven't had the please of unescaping it yet, but here it is.
I am a second language teacher. This is a .pl I have created as an online placement.
The student could type any manner of thing:

$in{'P1OC2Q1'} is input from <input type=text name="P1OC2Q1">

------snip--------
use URI::Escape;
$message = uri_escape($in{'P1OC2Q1'});
$message =~ s/\!/\%21/g;
$message =~ s/\?/\%3F/g;
$message =~ s/\;/\%3B/g;
$message =~ s/\:/\%3A/g;
$message =~ s/\&/\%26/g;
$message =~ s/\=/\%3D/g;
$in{'P1OC2Q1'}=$message;
-----snip-------

It gets passed like this:

-----snip-------
$Part1_URL_Encode  =
"&P1OC1=$in{'P1OC1'}&P1OC1Q1=$in{'P1OC1Q1'}&P1OC1Q2=$in{'P1OC1Q2'}&P1OC1Q3=$in{'P1OC1Q3'}&P1OC1Q4=$in{'P1OC1Q4'}&P1OC1Q5=$in{'P1OC1Q5'}&P1OC1Q6=$in{'P1OC1Q6'}";

-----snip-------
 print "<html>
<head>
<title>Complete the Text: Task 2</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<frameset rows=\"80,*\" cols=\"80,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">
  <frame name=\"cornerFrame\" scrolling=\"NO\" noresize src=\"$url_to_html/faithcorner.html\" >
  <frame name=\"topFrame\" scrolling=\"NO\" noresize src=\"$url_to_html/faithinst.html\" >
  <frame name=\"leftFrame\" src=\"$url_to_html/faithlist.html\" scrolling=\"AUTO\" noresize>
  <frame name=\"mainFrame\"
src=\"faithtext.cgi?$Part1_URL_Encode&P2WC1=$in{'P2WC1'}&P2WC2=$in{'P2WC2'}&P2WC3=$in{'P2WC3'}\">
</frameset>
<noframes>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
</body>
</noframes>
</html>
";




------------------------------

Date: Mon, 13 Aug 2001 23:31:12 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B784720.5010103@post.rwth-aachen.de>

jtjohnston wrote:
>>Yes, but I have my doubts that it is a problem with URI::un_escape. Can
>>you show us your original code?
>>
> 
> I haven't had the please of unescaping it yet, but here it is.
> I am a second language teacher. This is a .pl I have created as an online placement.
> The student could type any manner of thing:
> 
> $in{'P1OC2Q1'} is input from <input type=text name="P1OC2Q1">
> 
> ------snip--------
> use URI::Escape;
> $message = uri_escape($in{'P1OC2Q1'});
> $message =~ s/\!/\%21/g;
> $message =~ s/\?/\%3F/g;
> $message =~ s/\;/\%3B/g;
> $message =~ s/\:/\%3A/g;
> $message =~ s/\&/\%26/g;
> $message =~ s/\=/\%3D/g;
> $in{'P1OC2Q1'}=$message;

Could be shortened to:

$in{'P1OC2Q1'} = uri_escape($in{'P1OC2Q1'}, "^A-Za-z");

This should escape all characters that are not ordinary letters.


[...]

>  print "<html>
> <head>
[snipped HUGE string]
> ";

You might want to consider using HERE-docs:

print <<EOF;
<html><head>
etc...
EOF


Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Mon, 13 Aug 2001 16:36:06 -0500
From: "Michael D. Kirkpatrick" <wizard@psychodad.com>
Subject: Re: Uploading a file via a browser w/out using CGI.pm
Message-Id: <3B784846.FAC7DE7C@psychodad.com>

Leo Hemmings wrote:

> Hi all,
>
> I need to develop a script to upload files to a web server via a html form
> but without using CGI.pm. I have used CGI.pm to do this successfully but
> need to be able to do it without that module installed. I currently parse
> STDIN from GET and POST methods with the routine below:
>
> sub readform {
>         read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
>         my @pairs = split(/&/, $input);
>         foreach my $pair (@pairs) {
>                 (my $name,my $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;
>                 $FORM{$name} = $value;
>         }
>         my @vars = split(/&/, $ENV{QUERY_STRING});
>         foreach my $var (@vars) {
>                 (my $v,my $i) = split(/=/, $var);
>                 $v =~ tr/+/ /;
>                 $v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>                 $i =~ tr/+/ /;
>                 $i =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>                 $i =~ s/<!--(.|\n)*-->//g;
>                 $INFO{$v} = $i;
>         }
>         $action = $INFO{'action'};
>         $section = $INFO{'section'};
> }
>
> Now this works perfectly for all GET and POST requests that I need. However
> I am at a loss as to know where to begin including the 'file upload'
> routines that are in CGI.pm into this routine. Currently and data sent via
> POST in a form which uses <form enctype="multipart/form-data"> does not get
> loaded into my hash %FORM. Any ideas would be greatly appreciated. Would it
> be possible for instance to 'rip' out the appropriate code from CGI.pm and
> include it in my routine?
>
> Thankyou in advance,
> Leo
>
> P.S. I know I'm doing it the hard way but CGI.pm is just not an option for
> my application.

I wrote a script that handles uploads without CGI.pm.

Here is something you may want to do to get an idea of what is happening behind
the scenes:
Create a simple script that sends the contents of the buffer back to the
browser.  Use the standard "Content-type: text/html" header.  Just view the
source to see the true coding.  Just make sure you upload a small file to the
script (less then 5k) to see what is going on.  When you capture the file in
perl, just directly save it:

open (OUT, $filename);
print OUT $the_file;
close(OUT);

Do not cut out any carriage returns from the file .  When you look at the buffer
content, you will see what I mean...



------------------------------

Date: Mon, 13 Aug 2001 20:11:10 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: URL Encode
Message-Id: <3B78328A.48947562@courrier.usherb.ca>

Thanks Ilya. Much appreciated. Embarrassing as it is, I am running a minimal
copy of perl.exe (for Windows) with libnet only. Where else can I access
perldocs? Must be something online to consult?

John

Ilya Martynov wrote:

> >> use URI::Escape
>
> j> Please, do you have an example?
>
> Did you tried to read documentation (perldoc URI::Escape)? This module
> is very simple and IMHO it is obvious how to use it once you have read
> its docs. I'll give example this time but please try first to read
> docs.
>
>     use URI::Escape;
>
>     $message = "what a nice day it's going to be!"
>     $message = uri_escape($message);
>     http://www.nowhere.com/something.cgi?$message
>
> --
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)                                    |
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
> | AGAVA Software Company (http://www.agava.com/)                          |
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



------------------------------

Date: Mon, 13 Aug 2001 22:17:16 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: URL Encode
Message-Id: <3B7835CC.2090908@post.rwth-aachen.de>

jtjohnston wrote:
> Thanks Ilya. Much appreciated. Embarrassing as it is, I am running a minimal
> copy of perl.exe (for Windows) with libnet only. Where else can I access
> perldocs? Must be something online to consult?

Yes, you can do that at http://www.perldoc.com/ if you haven't installed 
them locally on your box.
Yet, in my estimation perldoc is one of Perl's killer-features. I surely 
would not want to miss it.
As for the documentation of some modules that are not covered by 
perldoc.com. You can always go to http://search.cpan.org, search for a 
particular module and view the manpages there. It coverser the whole of 
CPAN.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Mon, 13 Aug 2001 20:28:41 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: URL Encode
Message-Id: <3B7836A4.BBB4DAC8@courrier.usherb.ca>

Just another Perl hacker

Cool!




------------------------------

Date: Mon, 13 Aug 2001 22:41:55 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: URL Encode
Message-Id: <3B783B93.90703@post.rwth-aachen.de>

jtjohnston wrote:
> Just another Perl hacker
> 
> Cool!

Something called JAPH in short. If you find blurry and noisy lines as 
signatures in people's posts, you may present them to the Perl 
interpreter and wait excitedly for the output. The above result isn't 
really a surprise for the 'insider'. ;-)

Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: 13 Aug 2001 19:50:29 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: validate IP address
Message-Id: <9l9b25$264$1@news.orst.edu>

In article <9knjf5$2ns$1@suaar1aa.prod.compuserve.com>,
Richard A. Evans <EvR@compuserve.com> wrote:
>> You're missing that the from xxx.xxx.xxx.xx is not the only valid form for
>> ip addresses.
>
>I was responding to the comments that said:
>
>If you mean valid as in "correct number of numbers", a short regular
>expression will do the trick:
>
>  $ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
>  # make sure you have four digit sequences 1-3 numbers each, separated by
>periods,
>  # and that the IP takes up the entire variable

127.1 has "the correct number of numbers". 324156926 has "the correct
number of numbers".  Any test that results in 127.1 being rejected is
incorrect.



------------------------------

Date: Mon, 13 Aug 2001 20:54:20 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: VIER/NEUN problem
Message-Id: <tngfjsjdbla9a@corp.supernews.com>

[Note: this was also posted to fwp.]

According to <URL:http://www.vector.org.uk/v174/puzzl174.htm>:

    On March the first, Steve Graham posted the following message in a
    few discussion groups related to programming languages:

	This puzzle was originally posted on a mailing list for the
	Icon programming language. Thought members of this group might
	also want to give it a shot.

	VIER and NEUN represent 4-digit squares, each letter denoting a
	distinct digit. You are asked to find the value of each, given
	the further requirement that each uniquely determines the
	other.

	The "further requirement" means that of the numerous pairs of
	answers, choose the one in which each number only appears once
	in all of the pairs.

Here's a solution from map/grep Hell.  (Randal should love it. :-)

    #! /usr/local/bin/perl -w

    # VIER/NEUN problem

    use strict;

    use POSIX qw/ ceil floor /;

    my $expr = qr/
        ^

        (.)                     # V
        ((?!\1)             .)  # I
        ((?!\1|\2)          .)  # E
        ((?!\1|\2|\3)       .)  # R

        ((?!\1|\2|\3|\4)    .)  # N
        \3                      # E
        ((?!\1|\2|\3|\4|\5) .)  # U
        \5                      # N

        $
    /x;

    my $lo = ceil  sqrt 1000;
    my $hi = floor sqrt 9999;

    my %seen;

    $" = '';
    my @list = map  {             $_->[0] }
               grep {             $_->[1] == 2 }
               map  { [ $_, $seen{$_->[0]} + $seen{$_->[1]} ] }
               grep { "@$_" =~ /$expr/  && ++$seen{$_->[0]}
                                        && ++$seen{$_->[1]} }
               map  { $% = $_;  map { [ $_ * $_, $% ] } $lo .. $hi }
               grep { /^(.)..\1$/ }
               map  { $_ * $_ }
               $lo .. $hi;

    if (@list != 1) {
        $_ = @list;
        warn "$0: expected one result, got $_:\n";

        for (@list) {
            print "VIER = $_->[0], NEUN = $_->[1]\n";
        }
    }

    my($soln) = @list;
    print "VIER = $soln->[0], NEUN = $soln->[1]\n";

Enjoy,
Greg
-- 
 /"\
 \ /   ASCII RIBBON CAMPAIGN
  X  Against HTML Mail and News
 / \


------------------------------

Date: 13 Aug 2001 13:06:09 -0700
From: jbcamel@mediaone.net (Jane B.)
Subject: Way to do database read to disk instead of memory?
Message-Id: <f1231833.0108131206.8d6bd2@posting.google.com>

Question:

If I run a 'select' statement from Perl that retrieves thousands of
rows into an array, that data is stored in memory (correct?).

Is there a variable that can be set to tell Perl to store that data
temporarily on disk?

I need to query two tables, save the data into two arrays and then
process the data.  This is the only way to get the output that I need.
 However I know that I'm going to have memory problems if all the data
is saved to memory.  The database in Informix.  I'm running Perl on a
Unix platform.

Thanks

Jane


------------------------------

Date: Mon, 13 Aug 2001 21:49:16 +0200
From: Philip Newton <pne-news-20010813@newton.digitalspace.net>
Subject: Re: whither tchrist?
Message-Id: <uhbgnt0jlsd2sof1od62fu6govbc0682m6@4ax.com>

On Mon, 13 Aug 2001 13:17:28 -0000, klassa@cisco.com (John Klassa)
wrote:

> What happened to Tom Christiansen?  Granted, I didn't go to the
> conference this year, so I don't know if he was there...  Yet, he's
> been silent here for a while, and I haven't seen any of his stuff
> anywhere (or even seen him mentioned) in a while.  Long sabbatical?
> Burnout?  Heavily involved in a new project?

Here's half an answer: Last year he was so up to his ears in work with
preparing Camel Mk III for publication that he hardly had time to
breathe (according to his email autoresponder).

Can't say what he's up to at the moment, however. The last time I saw
him was at yapc::Europe::19100 last September.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


------------------------------

Date: Mon, 13 Aug 2001 19:46:53 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: whither tchrist?
Message-Id: <N8Wd7.246439$v5.25326895@news1.rdc1.ct.home.com>

John Klassa <klassa@cisco.com> wrote:
> What happened to Tom Christiansen?  Granted, I didn't go to the
> conference this year, so I don't know if he was there...  Yet, he's
> been silent here for a while, and I haven't seen any of his stuff
> anywhere (or even seen him mentioned) in a while.  Long sabbatical?
> Burnout?  Heavily involved in a new project?

Tom was at TPC this year. I think he's currently in the blissful
throes of Real Life, and isn't spending all that much time with
computers in general. (And good for him, honestly. He looked
like he was having fun)

					Dan


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 V10 Issue 1512
***************************************


home help back first fref pref prev next nref lref last post