[16305] in Perl-Users-Digest
Perl-Users Digest, Issue: 3717 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 10:08:00 2000
Date: Tue, 18 Jul 2000 07:07:48 -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: <963929268-v9-i3717@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 18 Jul 2000 Volume: 9 Number: 3717
Today's topics:
How to read and show 10 lines (nikita)
Re: How to read and show 10 lines (Tim Tompkins)
Https URL checking LWP simple ()
Re: Https URL checking LWP simple (Jonathan Stowe)
I need some advice (Filipe de Matos)
Re: I need some advice (Mariusz £)
Installing ActivePerl : Problem (Jan Buys)
Re: Installing ActivePerl : Problem (Thomas L. Shinnick)
installing XML::DOM (Hyer Bercaw)
Re: installing XML::DOM (Cal Henderson)
Re: Interfacing Perl with MIME : help needed (Anno Siegel)
Re: Interfacing Perl with MIME : help needed (Abigail)
Re: Is there a better way (Multi-dimen. Arrays) ()
Re: Is there a better way (Multi-dimen. Arrays) (John Fortin)
Re: Is there a Perl bug list? (Jonathan Stowe)
Re: Is there a Perl bug list? (Mark Lewis)
Re: Is there a Perl bug list? (Jonathan Stowe)
Keeping a copy of STDIN (Rob Sedgwick)
Re: Keeping a copy of STDIN (jason)
limits on GET (Joshua McAdams)
Re: limits on GET <flavell@mail.cern.ch>
Re: limits on GET (Prasanth A. Kumar)
Re: limits on GET (jason)
Re: limits on GET (Godzilla!)
Re: limits on GET (Eric Bohlman)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jul 2000 23:30:01 GMT
From: nikitta@ica.net.bbs@openbazaar.net (nikita)
Subject: How to read and show 10 lines
Message-Id: <3bQdYQ$WDz@openbazaar.net>
Hi everybody.
I need your help
How to force the program read and show only, in my case, 10 lines of a
database
and then continue until all database are shown?
This fragment of program counts 10 lines of a database and stops.
How to continue next 10 lines until all the database will be shown?
First time $counter is at 0. How can I overwrite the value 0 of the
$counter in $start_number, in my case this is 10?
Thanks in advance,
Serguei
# a flat data is written in $filename in this way:
#
"($num,$one,$two,$line1,$line2,$line3,$three,$four,$five,$six,$seven,\n";
#=======================================================================
$display_num = 10;
&get_number;
print "<table >\n";
print "<tr><td><form action=\"$main_script\" method = \"post\">\n";
print "<input type= \"hidden\" name =\"begin\" value =
\"$start_number\">
print "<input type= \"hidden\" name =\"end\" value = \"$stop_number\">
print "<input type= \"submit\" value = \">>>>\">\n"
print "<b>Found: $start_number - $stop_number from
$num_display<\b></form>\n";
print "</td></tr></table>\n";
#========================================================================
sub get_number {
open(FDATA,"$filename") || die $!;
chomp(@datafile = <FDATA>);
close(FDATA);
my $num_display = @datafile;
my $counter = 0;
my $start_num = $counter;
my $stop_num = $counter + $display_num;
if ($stop_num > $num_display ) {
$stop_num = $num_display;
}
foreach (@datafile) {
my @data = split /\|/;
my $number = shift(@data);
if ($number != 0) {
&write data;
$counter++;
until ($counter == $stop_num);
}
return ($num_display, $start_num, $stop_num);
}
------------------------------
Date: 17 Jul 2000 07:30:02 GMT
From: ttompkins@uswest.net.bbs@openbazaar.net (Tim Tompkins)
Subject: Re: How to read and show 10 lines
Message-Id: <3bR4AQ$WHq@openbazaar.net>
There are two main approaches to this problem depending upon the
application.
1. Reading N consecutive rows from an arbitrary starting point, and
finishing.
2. Paging through the entire datafile N rows at a time; continuing with
valid user input.
Approach 1: Reading N consecutive rows from an arbitrary starting point, and
finishing.
Given:
page_size => $page,
start_point => $start,
data_file => $filename
------- Begin Script -------
#!/usr/bin/perl
use strict;
my $page = 10;
my $start = $ARGV[0];
my $filename = '/path/to/data/file';
my @data = read_lines($page, $start, $filename);
for my $line (@data) {
# call parse_data() on $line and print it
my $data = parse_data( $line );
# assuming $data is a hashref...
print join (', ', map { "$_ => $data->{$_}" } (keys %$data)), "\n";
}
sub read_lines {
my ($p,$s,$f) = @_;
$p ||= 10;
$s ||= 1;
(-e $f) || die("File, $f, does not exist.\n");
local(*FH);
open(FH, $f) || die("Unable to read $f: $!\n");
my $row = 0;
my @lines;
while(<FH>) {
next unless ++$row >= $s;
push @lines, $_;
last if @lines == $p;
}
close(FH);
chomp(@lines);
return(@lines);
}
sub parse_data {
my $line = shift;
# Add your code here to split out the data fields
# This application assumes that you will be returning a hash reference.
# Its construct may be similar to the following:
# Pipe delimeted key=value fields -- "key1=25|key2=value 2|key3=hello
world"
my $dat = {};
for my $pair ( split /\|/, $line ) {
my($key,$val) = ( split /=/, $pair );
$dat->{$key} = $val;
}
return $dat;
}
__END__
Approach 2:
given:
page_size => $page,
start_point => $start,
data_file => $filename
------- Begin Script -------
#!/usr/bin/perl
use strict;
$| = 1;
my $page = 10;
my $start = $ARGV[0];
my $filename = '/path/to/data/file';
open(FH, $filename) || die("Unable to open $filename: $!\n");
my $on = 0;
while (my $line = <FH>) {
my $data = parse_data( $line );
# assuming $data is a hashref...
print ++$on, ". ", join (', ', map { "$_ => $data->{$_}" } (keys
%$data)), "\n";
if ($on % $page == 0) {
print "Continue? (Y/n) \n> ";
my $yn = <>;
last if $yn =~ /n/i;
}
}
sub parse_data {
my $line = shift;
# Add your code here to split out the data fields
# This application assumes that you will be returning a hash reference.
# Its construct may be similar to the following:
# Pipe delimeted key=value fields -- "key1=25|key2=value 2|key3=hello
world"
my $dat = {};
for my $pair ( split /\|/, $line ) {
my($key,$val) = ( split /=/, $pair );
$dat->{$key} = $val;
}
return $dat;
}
__END__
NOTE:
Approach 1 will work for either CGI or command line while approach 2 will
work only on the command line. You'll obviously want to use a CGI param
instead of %ARGV for the starting point (see: perdoc CGI ).
Thanks,
Tim Tompkins
----------------------------------------------
Programmer / Staff Engineer
http://www.arttoday.com/
----------------------------------------------
------------------------------
Date: 17 Jul 2000 17:00:01 GMT
From: lucap@my-deja.com.bbs@openbazaar.net ()
Subject: Https URL checking LWP simple
Message-Id: <3bRJ31$Wfw@openbazaar.net>
i'm using LWP:simple for a quick url check:
if (head($url)) {
...
}
I just found that this does not accept https addresses,
any workarounds ?
Thanks, ciao
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Jul 2000 08:00:11 GMT
From: gellyfish@gellyfish.com.bbs@openbazaar.net (Jonathan Stowe)
Subject: Re: Https URL checking LWP simple
Message-Id: <3bRgOD$UuM@openbazaar.net>
On Mon, 17 Jul 2000 16:46:17 GMT lucap@my-deja.com wrote:
>
>
> i'm using LWP:simple for a quick url check:
>
> if (head($url)) {
>
> ...
> }
>
> I just found that this does not accept https addresses,
>
> any workarounds ?
>
You will need to install Net::SSL and use LWP::UserAgent ....
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 17 Jul 2000 15:50:01 GMT
From: dematos@my-deja.com.bbs@openbazaar.net (Filipe de Matos)
Subject: I need some advice
Message-Id: <3bRHBP$VGC@openbazaar.net>
Hi all,
I´m working for a german Company as SysAdmin.
On the intranet there are 40 workstations (Linux/HP-UX/Windows)
that have access to a so called "Information server" placed behind
a Apache Webserver. This are a bunch of information that have been
growing significantly in the last time.
At the beginning i started to write some CGI scripts, accessing
PostgreSQL that´s where all the data is stored. The only modules
that í´ve looked for were Postgres.pl and CGI-Perl.
But soon i´ve realized that this scripts are very difficult to maintain.
On the one side the Database queries, on the other side the HTML
processing and output.
Now i´m looking for some way to separate the perl code from the HTML
as much as possible.
I´ve been reading about "HTML::Template", "embPerl", "ePerl", etc...
but i don´t have any experience with any of them. Something that isn´t
obvious to me is if i still can write my code with "normal" perl
tags or if i only can use a set of module specific language elements.
Still i can call other modules like Postgres.PL to access my database
from inside of this scripts (or even from inside embedded perl)?
If you´ve already done something similar, your advice would be helpful.
Which one is the best option for this kind of projects ?
Thank you guys
Matos
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Jul 2000 08:20:05 GMT
From: mariusz.lukasiewicz@lido-tech.net.bbs@openbazaar.net (Mariusz £)
Subject: Re: I need some advice
Message-Id: <3bRh14$Vi5@openbazaar.net>
--------------68422892DCAB8BC1DC0E2718
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Hi
If you want to distinct HTML from pure perl code try to use perl formats
It's simple mechanism for creating reports.
Type:
perldoc perlform
--
Rgds
Mariusz.
----------------------------------------------------------------
Mariusz £ukasiewicz Lido Mail: lukmar1@mail.lido-tech tel. ext 30
Lido Technology E-mail : mariusz.lukasiewicz@lido-tech.net
--------------68422892DCAB8BC1DC0E2718
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi
<p>If you want to distinct HTML from pure perl code try to use perl formats
<br>It's simple mechanism for creating reports.
<br>Type:
<br>perldoc perlform
<br>
<br>
<br>
<pre>--
Rgds
Mariusz.
----------------------------------------------------------------
Mariusz £ukasiewicz Lido Mail: lukmar1@mail.lido-tech tel. ext 30
Lido Technology E-mail : mariusz.lukasiewicz@lido-tech.net</pre>
</html>
--------------68422892DCAB8BC1DC0E2718--
------------------------------
Date: 17 Jul 2000 14:20:01 GMT
From: jan.buys@mcd.alcatel.be.bbs@openbazaar.net (Jan Buys)
Subject: Installing ActivePerl : Problem
Message-Id: <3bREh3$V0S@openbazaar.net>
This is a multi-part message in MIME format.
--------------F76245EA0EBABF5137CF9E2B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi all,
I'm trying to install ActivePerl (which I downloaded from the official
Activestate site), but I cannot get the MS Windows installer to work,
which is needed to install the .msi file to which the perl distribution
is packed.
Anyone with the same problem, and ... eh ... solution of course ?
Thanks in advance...
--------------F76245EA0EBABF5137CF9E2B
Content-Type: text/x-vcard; charset=us-ascii;
name="jan.buys.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Jan Buys
Content-Disposition: attachment;
filename="jan.buys.vcf"
begin:vcard
n:Buys;Jan
tel;work:+32-3-450.30.12
x-mozilla-html:FALSE
org:Alcatel Bell - RCD - VG24
adr:;;;;;;
version:2.1
email;internet:jan.buys@mcd.alcatel.be
title:Tools & Methodology
x-mozilla-cpt:;2320
fn:Jan Buys
end:vcard
--------------F76245EA0EBABF5137CF9E2B--
------------------------------
Date: 17 Jul 2000 16:30:03 GMT
From: tshinnic@io.com.bbs@openbazaar.net (Thomas L. Shinnick)
Subject: Re: Installing ActivePerl : Problem
Message-Id: <3bRIDS$UKN@openbazaar.net>
On Mon, 17 Jul 2000 16:16:01 +0200, Jan Buys <jan.buys@mcd.alcatel.be> wrote:
>Hi all,
>
>I'm trying to install ActivePerl (which I downloaded from the official
>Activestate site), but I cannot get the MS Windows installer to work,
>which is needed to install the .msi file to which the perl distribution
>is packed.
>Anyone with the same problem, and ... eh ... solution of course ?
And the error messages/symptoms were? The version of ActivePerl was?
And the windows version was which (95/98/NT/2000) ?
Might your problem have anything to do with the following third paragraph
on the AS download page:
Windows Users: This installation requires the version 1.1 or
greater of the Windows Installer. Download it here for
Windows NT or Windows 95/98. Windows 2000 users do not
need this file since they already have the Windows
Installer installed.
I ran into this on NT4.0, so you might also. The referenced links were:
http://www.activestate.com/download/contrib/Microsoft/NT/InstMsi.exe
http://www.activestate.com/download/contrib/Microsoft/9x/InstMsi.exe
>
>Thanks in advance...
--
I'm a pessimist about probabilities; I'm an optimist about possibilities.
Lewis Mumford
------------------------------
Date: 17 Jul 2000 04:40:04 GMT
From: john_hyer_bercaw@hotmail.com.bbs@openbazaar.net (Hyer Bercaw)
Subject: installing XML::DOM
Message-Id: <3bQlc4$TXe@openbazaar.net>
I have used PPM to successfuly install XML::DOM on Win98, but I keep getting
errors when I try to install it on Win2000. Any ideas?
Thanks,
Hyer
------------------------------
Date: 17 Jul 2000 09:40:05 GMT
From: cal@iamcal.com.bbs@openbazaar.net (Cal Henderson)
Subject: Re: installing XML::DOM
Message-Id: <3bR7T6$VKL@openbazaar.net>
"Hyer Bercaw" <john_hyer_bercaw@hotmail.com> wrote:
: I have used PPM to successfuly install XML::DOM on Win98, but I keep getting
: errors when I try to install it on Win2000. Any ideas?
:
: Thanks,
:
: Hyer
Which errors in particular?
--
Cal Henderson
sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);
------------------------------
Date: 18 Jul 2000 11:18:25 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Interfacing Perl with MIME : help needed
Message-Id: <8l1ee1$h79$1@lublin.zrz.tu-berlin.de>
Abigail <abigail@delanet.com> wrote in comp.lang.perl.misc:
[newsgroups trimmed]
> print while <__DATA__>;
<DATA>
> __DATA__
Anno
------------------------------
Date: 17 Jul 2000 20:00:10 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: Interfacing Perl with MIME : help needed
Message-Id: <3bRNaC$W9o@openbazaar.net>
Bo (bo@bo.com) wrote on MMDXI September MCMXCIII in
<URL:news:8kr8gj$k54$1@slb7.atl.mindspring.net>:
`` We have a user who needs to send web-based mail in *plain-text*
`` format, WHILE attaching .jpeg images to the messages, which would seem
`` to involve MIME. Can this be done with Perl scripts and how?
Yes. It's simple:
#!/opt/perl/bin/perl -w
use strict;
print while <__DATA__>;
__DATA__
... plain text ...
... mime crap ...
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 14 Jul 2000 16:50:02 GMT
From: nobull@mail.com.bbs@openbazaar.net ()
Subject: Re: Is there a better way (Multi-dimen. Arrays)
Message-Id: <3bP2ET$Xbj@openbazaar.net>
John Fortin <fortinj@attglobal.net> writes:
> Is there a better way to add data to a "multi-dimentional" array than
> this... See line marked with <==========
Give the stuff surrounding it no it is the best way to do what you are doing.
> This code works, but this line seems clunky.
No, actually it is the code either side that's clunky.
Of course the clunkiest thing about your script is the formatting
which makes it almost impossible to reaf.
I've fixed that below.
> sub GetPCSteps {
>
> my @data = @_;
> my @steps;
> my $stepcounter = 0;
>
> while (@data) {
> do {
> $data[0] =~ s/\s+$//;
> $data[0] = $data[0]."\n";
> push @{$steps[$stepcounter]}, $data[0];
> shift @data;
> } until (!@data || $data[0] =~ /^DATE:/);
> $stepcounter++;
> }
>
> for (my $x = 0; $x <= $#steps; $x++) {
> for (my $y = 0; $y <= $#{$steps[$x]}; $y++) {
> print $steps[$x][$y];
> }
> }
> }
There are lots of ways to do it but I would do:
sub GetPCSteps {
my @steps;
local $_;
while (@_) {
my @row;
while (@_) {
$_ = shift;
last if /^DATE:/;
s/\s*$/\n/;
push @row, $_;
}
push @steps, \@row;
}
print @$_ for @steps;
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 14 Jul 2000 17:20:02 GMT
From: fortinj@attglobal.net.bbs@openbazaar.net (John Fortin)
Subject: Re: Is there a better way (Multi-dimen. Arrays)
Message-Id: <3bP345$Xjj@openbazaar.net>
nobull@mail.com wrote:
>
> John Fortin <fortinj@attglobal.net> writes:
>
> > Is there a better way to add data to a "multi-dimentional" array than
> > this... See line marked with <==========
>
> Give the stuff surrounding it no it is the best way to do what you are doing.
>
> > This code works, but this line seems clunky.
>
> No, actually it is the code either side that's clunky.
Beauty is in the eye of the beholder :) To be honest, your solution is
the better perl solution, but I find it harder to read.
>
> Of course the clunkiest thing about your script is the formatting
> which makes it almost impossible to reaf.
I don't know what happened. It was fine when I sent it. Maybe the
Netscape mail client screwed it up.
>
> I've fixed that below.
>
> > sub GetPCSteps {
> >
> > my @data = @_;
> > my @steps;
> > my $stepcounter = 0;
> >
> > while (@data) {
> > do {
> > $data[0] =~ s/\s+$//;
> > $data[0] = $data[0]."\n";
realized that this is better after I sent post: $data[0] =~ s/\s+$/\n/;
> > push @{$steps[$stepcounter]}, $data[0];
> > shift @data;
> > } until (!@data || $data[0] =~ /^DATE:/);
> > $stepcounter++;
> > }
> >
> > for (my $x = 0; $x <= $#steps; $x++) {
> > for (my $y = 0; $y <= $#{$steps[$x]}; $y++) {
> > print $steps[$x][$y];
> > }
Here I really wanted to iterate the array one by one in this manner.
> > }
> > }
>
> There are lots of ways to do it but I would do:
>
> sub GetPCSteps {
> my @steps;
> local $_;
>
> while (@_) {
> my @row;
> while (@_) {
> $_ = shift;
> last if /^DATE:/;
> s/\s*$/\n/;
> push @row, $_;
> }
> push @steps, \@row;
> }
>
> print @$_ for @steps;
Thanks for the input :)
John
------------------------------
Date: 16 Jul 2000 18:10:05 GMT
From: gellyfish@gellyfish.com.bbs@openbazaar.net (Jonathan Stowe)
Subject: Re: Is there a Perl bug list?
Message-Id: <3bQVIU$Xjh@openbazaar.net>
On Sun, 16 Jul 2000 03:18:58 GMT Mark Lewis wrote:
> Hello,
>
> Where can a comprehensive list of confirmed Perl bugs be found? The only
> thing I have be able to find is an outdated list at perl.com.
>
<http://bugs.perl.org> at a guess ...
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 17 Jul 2000 03:10:09 GMT
From: nospam.nicedoctor@hotmail.com.bbs@openbazaar.net (Mark Lewis)
Subject: Re: Is there a Perl bug list?
Message-Id: <3bQjLX$Vq3@openbazaar.net>
Jonathan Stowe wrote in message <8ksbpn$av5$1@orpheus.gellyfish.com>...
>On Sun, 16 Jul 2000 03:18:58 GMT Mark Lewis wrote:
>> Hello,
>>
>> Where can a comprehensive list of confirmed Perl bugs be found? The
only
>> thing I have be able to find is an outdated list at perl.com.
>>
>
><http://bugs.perl.org> at a guess ...
>
This seems to be what I'm looking for. I went to this website and tried
the database form with no luck. No matter what I enter in the form,
submitting the form results in a blank database form being returned. The
help info at the site doesn't help.
Can anyone instruct me as to how to use the database search form at
bugs.perl.org?
Thanks!
------------------------------
Date: 17 Jul 2000 15:40:02 GMT
From: gellyfish@gellyfish.com.bbs@openbazaar.net (Jonathan Stowe)
Subject: Re: Is there a Perl bug list?
Message-Id: <3bRGl4$UmO@openbazaar.net>
On Mon, 17 Jul 2000 03:15:41 GMT, Mark Lewis Wrote:
>
> Jonathan Stowe wrote in message <8ksbpn$av5$1@orpheus.gellyfish.com>...
>>On Sun, 16 Jul 2000 03:18:58 GMT Mark Lewis wrote:
>>> Hello,
>>>
>>> Where can a comprehensive list of confirmed Perl bugs be found? The
> only
>>> thing I have be able to find is an outdated list at perl.com.
>>>
>>
>><http://bugs.perl.org> at a guess ...
>>
>
>
> This seems to be what I'm looking for. I went to this website and tried
> the database form with no luck. No matter what I enter in the form,
> submitting the form results in a blank database form being returned. The
> help info at the site doesn't help.
>
> Can anyone instruct me as to how to use the database search form at
> bugs.perl.org?
>
But an asterisk in the subject field and press query ....
/J\
------------------------------
Date: 17 Jul 2000 06:30:02 GMT
From: newsgroups@justinfashanu.demon.co.uk.bbs@openbazaar.net (Rob Sedgwick)
Subject: Keeping a copy of STDIN
Message-Id: <3bR2VQ$Va9@openbazaar.net>
I would be grateful if someone in the know can help me with this problem. I
have a Perl CGI script which is used to process a HTML form. The script also
uses a Perl library file, cgi-lib.pl. Both are trying to exclusively access
STDIN, what I need to do is make a copy of it or somehow share it between
them.
Critical lines from my script:
require "./cgi-lib.pl";
$inpstr = <STDIN>;
Critical line from: cgi-lib.pl
if (($got = read(STDIN, $in, $len) != $len))
Scope comes to mind? Does a variable that is created in an external script
still exist in my local script? Or am I missing something really basic?
Any help is very much appreciated.
Rob
------------------------------
Date: 17 Jul 2000 06:50:03 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Keeping a copy of STDIN
Message-Id: <3bR38R$V43@openbazaar.net>
Rob Sedgwick wrote ..
>I would be grateful if someone in the know can help me with this problem. I
>have a Perl CGI script which is used to process a HTML form. The script also
>uses a Perl library file, cgi-lib.pl. Both are trying to exclusively access
>STDIN, what I need to do is make a copy of it or somehow share it between
>them.
>
>Critical lines from my script:
>
>require "./cgi-lib.pl";
>
>$inpstr = <STDIN>;
>
>Critical line from: cgi-lib.pl
>
>if (($got = read(STDIN, $in, $len) != $len))
>
>Scope comes to mind? Does a variable that is created in an external script
>still exist in my local script? Or am I missing something really basic?
why are you using cgi-lib.pl if you're going to handle STDIN yourself ?
.. in fact - why are you using it at all when the standard module CGI.pm
handles things much more gracefully
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 18 Jul 2000 03:00:03 GMT
From: jmcada@hotmail.com.bbs@openbazaar.net (Joshua McAdams)
Subject: limits on GET
Message-Id: <3bRYX4$V0M@openbazaar.net>
I am calling a cgi via A HREF and when I recieve my key/value pairs, I get
all but the last one. A wierd looking char is appearing instead. Is there
a limit on the size of the HREF I am passing.
here is the line that is being sent:
<a
href="http://classifiedcafe.com/cgi-bin/classifieds/classifieds.cgi?session_
key=39738f2539caa29a&modify_sections_input_form=on§ion_to_modify=RealEst
ate">Modify General Options</a>
// section_to_modify shows up as ion_to_modify=RealEstate in the browser
window and as soon as I get the string from the GET, it looks this way.
There is some odd char that shows up before it
Thanks in advance
jmcada
(Sorry if my terminology isn't the best... started with perl and cgi's
today)
------------------------------
Date: Tue, 18 Jul 2000 12:02:46 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: limits on GET
Message-Id: <Pine.GHP.4.21.0007181144460.16078-100000@hpplus03.cern.ch>
On Tue, 18 Jul 2000, Prasanth A. Kumar wrote:
> > This is actually an HTML problem; your browser is interpreting "§" as
> > an entity reference to a character representing a section symbol.
> > Ampersands in URLs that appear in HTML documents need to be escaped as &.
>
> This brings up a related question... in the Perl CGI module, is there
> a function to do the encoding for href inside of anchor tags?
CGI.pm's best answer is the one that's been in the HTML specifications
since HTML2.0/RFC1866; CGI.pm calls it "-newstyle_urls".
If you were determined to use -oldstyle_urls (which is what the
previous discussion amounts to), then you _could_ use CGI.pm's
"excapeHTML" method: all of the other HTML-significant characters
would already have been converted to %xx format by the URL-encoding
rules, so it's only the ampersand that you need to worry about.
(And since it's only ampersand that represents a problem, this is
one situation where I guess a hand-knitted solution would be just as
good as calling a CGI.pm method).
Remember, the naked ampersand is perfectly OK in the URL _as such_,
and the methods documented in CGI.pm explicitly state that they are
returning URLs (i.e not HREF= or SRC= attribute values). It's in
forming these attribute values that you would need to convert the
ampersands, if you use them. I'm looking at the proper HTML
docmentation (NOT the html-ised POD) for version 2.66: in the section
describing Pragmas, this is properly documented under -oldstyle_urls.
Oh, and http://ppewww.ph.gla.ac.uk/~flavell/www/formgetbyurl.html
However, CGI.pm versions that post-date the security alert CA-2000-02
go a bit overboard in encoding character data, in the interests of
defending against the risks described in that alert. I understand
that Lincoln Stein is still working on getting this into a form that
both works correctly for all character codings (charsets) _and_
defends against those risks. It's a nontrivial problem! Especially
as there's an additional security bug in X Netscape, treating codes
x8B and x9B as if they were '<' and '>', thus subverting filters which
test for HTML-significant characters.
cheers
------------------------------
Date: 18 Jul 2000 04:00:03 GMT
From: kumar1@home.com.bbs@openbazaar.net (Prasanth A. Kumar)
Subject: Re: limits on GET
Message-Id: <3bRaC6$VOM@openbazaar.net>
ebohlman@netcom.com (Eric Bohlman) writes:
> Joshua McAdams (jmcada@hotmail.com) wrote:
> : I am calling a cgi via A HREF and when I recieve my key/value pairs, I get
> : all but the last one. A wierd looking char is appearing instead. Is there
> : a limit on the size of the HREF I am passing.
> : here is the line that is being sent:
> : <a
> : href="http://classifiedcafe.com/cgi-bin/classifieds/classifieds.cgi?session_
> : key=39738f2539caa29a&modify_sections_input_form=on§ion_to_modify=RealEst
> : ate">Modify General Options</a>
> :
> : // section_to_modify shows up as ion_to_modify=RealEstate in the browser
> : window and as soon as I get the string from the GET, it looks this way.
> : There is some odd char that shows up before it
>
> This is actually an HTML problem; your browser is interpreting "§" as
> an entity reference to a character representing a section symbol.
> Ampersands in URLs that appear in HTML documents need to be escaped as &.
This brings up a related question... in the Perl CGI module, is there
a function to do the encoding for href inside of anchor tags?
--
Prasanth Kumar
kumar1@home.com
------------------------------
Date: 18 Jul 2000 03:20:06 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: limits on GET
Message-Id: <3bRZA6$U9k@openbazaar.net>
Joshua McAdams wrote ..
>I am calling a cgi via A HREF and when I recieve my key/value pairs, I get
>all but the last one. A wierd looking char is appearing instead. Is there
>a limit on the size of the HREF I am passing.
>here is the line that is being sent:
><a
>href="http://classifiedcafe.com/cgi-bin/classifieds/classifieds.cgi?session_
>key=39738f2539caa29a&modify_sections_input_form=on§ion_to_modify=RealEst
>ate">Modify General Options</a>
>
>// section_to_modify shows up as ion_to_modify=RealEstate in the browser
>window and as soon as I get the string from the GET, it looks this way.
>There is some odd char that shows up before it
there's a special HTML code
§
which should generate the char § when on a web page .. but you have to
have the semi-colon in there otherwise it shouldn't be interpreted AND
the ampersand would be used up with it as well - so you'd actually get a
modify_sections_input_form value equal to on§ion_to_modify=RealEstate
so .. the question arises - how is this being interpreted incorrectly ..
and I don't really know .. an easy workaround would be to rename that
parameter to something that doesn't start with sect .. like
modify_section
but take a look at the HTML of the page with the link on it - see if
there's a stray semi-colon in there
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 18 Jul 2000 04:00:03 GMT
From: godzilla@stomp.stomp.tokyo.bbs@openbazaar.net (Godzilla!)
Subject: Re: limits on GET
Message-Id: <3bRaC5$VKL@openbazaar.net>
Joshua McAdams wrote:
> I am calling a cgi via A HREF and when I recieve my key/value pairs, I get
> all but the last one. A wierd looking char is appearing instead. Is there
> a limit on the size of the HREF I am passing.
> here is the line that is being sent:
(snippage)
> ... §ion_to_modify=RealEst ...
> // section_to_modify shows up as ion_to_modify=RealEstate
> in the browser window and as soon as I get the string from
> the GET, it looks this way. There is some odd char that
> shows up before it
Change §ion to: &§ection
&§ection_to_modify=RealEstate
Much prettier, don't you think?
Guaranteed your problem will vanish.
Prudent advice would be to suggest
you research "html entities" for
an authoritative answer.
> (Sorry if my terminology isn't the best...
> started with perl and cgi's today)
Honestly and truly?
Godzilla!
--
$godzilla = "godzilla rocks!";
srand(time() ^ ($$ + ($$ << 15)));
sub randcase
{ rand(40) < 20 ? "\u$1" : "\l$1" ; }
$godzilla =~ s/([a-z])/randcase($1)/gie;
print $godzilla; exit;
------------------------------
Date: 18 Jul 2000 03:40:04 GMT
From: ebohlman@netcom.com.bbs@openbazaar.net (Eric Bohlman)
Subject: Re: limits on GET
Message-Id: <3bRZZ4$WHc@openbazaar.net>
Joshua McAdams (jmcada@hotmail.com) wrote:
: I am calling a cgi via A HREF and when I recieve my key/value pairs, I get
: all but the last one. A wierd looking char is appearing instead. Is there
: a limit on the size of the HREF I am passing.
: here is the line that is being sent:
: <a
: href="http://classifiedcafe.com/cgi-bin/classifieds/classifieds.cgi?session_
: key=39738f2539caa29a&modify_sections_input_form=on§ion_to_modify=RealEst
: ate">Modify General Options</a>
:
: // section_to_modify shows up as ion_to_modify=RealEstate in the browser
: window and as soon as I get the string from the GET, it looks this way.
: There is some odd char that shows up before it
This is actually an HTML problem; your browser is interpreting "§" as
an entity reference to a character representing a section symbol.
Ampersands in URLs that appear in HTML documents need to be escaped as &.
------------------------------
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 3717
**************************************