[18900] in Perl-Users-Digest
Perl-Users Digest, Issue: 1068 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 5 21:11:03 2001
Date: Tue, 5 Jun 2001 18:10:20 -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: <991789819-v10-i1068@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 5 Jun 2001 Volume: 10 Number: 1068
Today's topics:
perl debugging questions (Michael Still)
Re: perl debugging questions (Clinton A. Pierce)
Re: Perl Regex Question (Tad McClellan)
Re: Perl Regex Question (Abigail)
Re: Perl Regex Question (Tad McClellan)
Re: Perl Server Problems (Tad McClellan)
Re: Perl Server Problems (Abigail)
Re: Process form WITHOUT feedback page PART 2 (GearGirl)
Re: Process form WITHOUT feedback page PART 2 (Jay Tilton)
Re: Process form WITHOUT feedback page PART 2 <godzilla@stomp.stomp.tokyo>
Setting cgi variable from form data (Wide Eyed)
Re: Setting cgi variable from form data <rsherman@ce.gatech.edu>
Re: Setting cgi variable from form data (David Efflandt)
Re: The FlakeyMind/Bryce Jacobs FAQ (v0.1) <lex@cc.gatech.edu>
Trying to create and "upload" field an print out the co <js@hotmail.com>
Re: Trying to create and "upload" field an print out th <trw@uakron.edu>
Re: using CGI and CGI::Cookie at the same time (David Efflandt)
Re: What am I doing wrong with this array operation? (Tad McClellan)
Re: What am I doing wrong with this array operation? (Tad McClellan)
Re: What am I doing wrong with this array operation? (Tad McClellan)
Re: What am I doing wrong with this array operation? <ren@tivoli.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jun 2001 15:41:48 -0700
From: mystill@yahoo.com (Michael Still)
Subject: perl debugging questions
Message-Id: <53abaf0f.0106051441.4d3d6a7@posting.google.com>
can someone take a look at this code and its associated error messages
and let me know how i can debug this?
-------------------------------------------------------
here's the errors:
%> perl -w e2000.pl # invoke the script from command line
Useless use of concatenation in void context at news.pm line 39.
Useless use of concatenation in void context at news.pm line 39.
Global symbol "screen" requires explicit package name at e2000.pl line
152.
Too many arguments for culture::dining at e2000.pl line 205, near "})
"
Too many arguments for culture::film at e2000.pl line 206, near "}) "
Too many arguments for culture::music at e2000.pl line 207, near "}) "
Too many arguments for culture::tv at e2000.pl line 208, near "}) "
Execution of e2000.pl aborted due to compilation errors.
%>
------------------------------------------------------
here's the script:
#! /spare/local/bin/perl -w
use strict;
use LWP::Simple;
use horoscope;
use news;
use weather;
use traffic;
use finance;
use culture;
use ad;
my $mso_path = '/content/web/edit/docs/shelter/msolist';
my $wmo_path = '/content/web/edit/docs/shelter/wmos';
my %pages = ('dominos_flat' => 'Advertisement',
'culture' => 'Culture',
'culture/charts/films' => 'Culture | Films',
'culture/charts/music' => 'Culture | Music',
'culture/charts/tv' => 'Culture | TV',
'culture/dining' => 'Culture | Dining',
'culture/horoscopes' => 'Culture | Horoscopes',
'culture/news' => 'Culture | News',
'finance' => 'Finance',
'finance/nyse' => 'Finance | NYSE Most Active',
'finance/nasd' => 'Finance | NASD Most Active',
'finance/markets' => 'Finance | Markets',
'finance/news' => 'Finance | News',
'news' => 'News',
'news/local' => 'News | Local',
'news/national' => 'News | National',
'news/sports' => 'News | Sports',
'news/international' => 'News | World',
'traffic' => 'Traffic',
'traffic/peninsula' => 'Traffic | Peninsula',
'weather' => 'Weather',
'weather/current_conditions' => 'Weather | Current',
'weather/forecast' => 'Weather | Forecast',
'weather/precipitation' => 'Weather | Precipitation',
);
my %signs = ( 'Aquarius', 'Jan 20 - Feb 18',
'Pisces', 'Feb 19 - Mar 19',
'Aries', 'Mar 20 - Apr 18',
'Taurus', 'Apr 19 - May 19',
'Gemini', 'May 20 - Jun 19',
'Cancer', 'Jun 20 - Jul 22',
'Leo', 'Jul 23 - Aug 21',
'Virgo', 'Aug 22 - Sep 21',
'Libra', 'Sep 22 - Oct 21',
'Scorpio', 'Oct 22 - Nov 21',
'Sagittarius', 'Nov 22 - Dec 20',
'Capricorn', 'Dec 21 - Jan 19',
);
print "Content-type: text/html\n\n";
my %fields;
foreach ( split('&', $ENV{QUERY_STRING}) )
{
my ($name, $value) = split('=');
$value =~ s/%([0-9a-fA-F][0-9a-fA-F])/chr(hex($1))/eg;
$value =~ tr/+/ /;
$fields{$name} = $value;
}
my ($background, $page, $subpage) = split('/', $fields{background});
my $title = join(' | ', ucfirst $background, ucfirst $page);
$title .= " | " . ucfirst $subpage if ($subpage);
$title =~ s/Culture/Entertain/;
$title =~ s/Entertain \| Charts/Media/;
$title =~ s/Current conditions/Forecast/;
$title =~ s/Horoscopes/Horoscope/;
$title = $pages{$fields{background}};
if ( $page =~ /penin/i) {
print <<EOF;
<html><head><title>$title</title></head>
<body background=/e2000/images/background/$background.jpg LEFTMARGIN=0
TOPMARGIN=0 text="#F0F0F0">
<table border=0 cellpadding=0 cellspacing=0>
<tr valign=top><td colspan=2 height=60 valign="bottom">
<img src="/e2000/images/blank.gif" border=0 height=58 width=105>
<!-- branding<img src="/e2000/images/msos/$fields{mso}.gif" WIDTH=115
HEIGHT=33 BORDER=0 ALT="$fields{mso}">-->
<img src="/e2000/images/blank.gif" border=0 height=50 width=130
ALT="">
<FONT FACE="Humanist 777 BT" SIZE="5"
COLOR="#99CCFF"><b>$title</b></font></td></tr>
<tr valign=top><td colspan=2 height=8><td> </td></tr>
<tr valign=top><td width=52></td><td height=300 width=500>
EOF
print make_page("$page$subpage");
print "</td></tr></table>\n</body></html>\n";
}
elsif ( $page )
{
my $sign = $fields{sign};
$title .= " | $sign" if $page eq 'horoscopes';
print <<EOF;
<html><head><title>$title</title></head>
<body background=/e2000/images/background/$background.jpg LEFTMARGIN=0
TOPMARGIN=0 text="#F0F0F0">
<table border=0 cellpadding=0 cellspacing=0>
<tr valign=top><td colspan=2 height=60 valign="bottom">
<img src="/e2000/images/blank.gif" border=0 height=58 width=105>
<!-- branding<img src="/e2000/images/msos/$fields{mso}.gif" WIDTH=115
HEIGHT=33 BORDER=0 ALT="$fields{mso}">-->
<img src="/e2000/images/blank.gif" border=0 height=50 width=130
ALT="">
<FONT FACE="Humanist 777 BT" SIZE="5"
COLOR="#99CCFF"><b>$title</b></font></td></tr>
<tr valign=top><td colspan=2 height=6><td> </td></tr>
<tr valign=top><td width=90></td>
EOF
print "<td height=300 width=500>\n";
print '<font face="Humanist 777 BT" size=6>',
make_page("$page$subpage"), '</font></td></tr>', "\n";
print "</table>\n</body></html>\n";
}
elsif ( $background )
{
print <<EOF;
<html><head><title>$title</title></head>
<body background=/e2000/images/foreground/$background.jpg
text="FFFFFF">
<table border=0 cellpadding=0 cellspacing=0>
<tr valign=top><td colspan=2 height=45 valign="bottom">
<img src="/e2000/images/blank.gif" border=0 height=10 width=92>
<!--<img src="/e2000/images/msos/$fields{mso}2.gif" BORDER=0
ALT="$fields{mso}">-->
</td></tr></table>
</body></html>
EOF
}
else
{
my %mso;
open(MSO, $mso_path);
foreach ( <MSO> )
{ $mso{$1} = 1 if /^([^\/]+)/ }
close(MSO);
my @mso = sort keys %mso;
my $mso_list = join("\n", map {"<option value=\"$_\">$_"} @mso);
open(WMO, $wmo_path);
my @wmo = <WMO>;
close(WMO);
chomp @wmo;
my $wmo_list = join("\n", map {"<option value=\"$_\">$_"} @wmo);
$wmo_list =~ s/value="SFO"/value="SFO" selected/m;
my $sign_list = join("\n", map {"<option value=\"$_\">$_,
$signs{$_}"} sort keys %signs);
my $screen_list = join("\n", map {"<option value=\"$_\">$_"}
@screen);
print <<EOF;
<html><head><title>E2000 Page Generator</title></head>
<body>
<H3>E2000 Page Generator</H3>
<form>
<table><tr valign=bottom>
<td>Select a page:<br>
<select name="background">
EOF
foreach ( sort keys %pages )
{ print "<option value=\"$_\">$pages{$_}\n"; }
print <<EOF;
</select></td>
<td>MSO<br>
<select name="mso">
$mso_list
</select></td>
<td><input type=submit value="Go"></td>
</tr></table>
Screen Number:
<SELECT NAME="screen">
$screen_list
</SELECT><BR>
Horoscope Sign:
<SELECT NAME="sign">
$sign_list
</SELECT><br>
Airport code (for Weather pages):
<select name="wmo">
$wmo_list
</select>
</form>
<hr>New! Advertisement for Domino's Pizza
</body></html>
EOF
}
sub make_page($)
{
my ($page) = @_;
if ( $page eq 'news' )
{
$page = $background eq 'culture'? 'entertainment': 'financial';
return news::current($page, $fields{screen});
}
elsif ( $page =~ /national|sports|world/
) { return news::current($page, $fields{screen}) }
elsif ( $page eq 'current_conditions'
) { return weather::current($fields{wmo}) }
elsif ( $page eq 'precipitation'
) { return weather::precipitation($fields{wmo}) }
elsif ( $page eq 'horoscopes' ) { return
horoscope::current($fields{sign}) }
elsif ( $page eq 'dining' ) { return
culture::dining($fields{screen}) }
elsif ( $page eq 'chartsfilms' ) { return
culture::film($fields{screen}) }
elsif ( $page eq 'chartsmusic' ) { return
culture::music($fields{screen}) }
elsif ( $page eq 'chartstv' ) { return
culture::tv($fields{screen}) }
elsif ( $page eq 'peninsula' ) { return
traffic::current($fields{wmo}) }
elsif ( $page =~ /nyse|nasd/ ) { return finance::stocks($page)
}
elsif ( $page =~ /markets/ ) { return
finance::markets() }
elsif ( $page =~ /local/) { return news::local($fields{screen},
$fields{wmo}) }
elsif ( $page eq 'dominos_flat' ) { return ad::dominos() }
else
{ return 'This is a test' }
}
------------------------------
Date: Wed, 06 Jun 2001 00:29:10 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: perl debugging questions
Message-Id: <qPeT6.34363$DG1.5854685@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <53abaf0f.0106051441.4d3d6a7@posting.google.com>,
mystill@yahoo.com (Michael Still) writes:
> can someone take a look at this code and its associated error messages
> and let me know how i can debug this?
By reading the error messages and comparing that against what's in diagnostics.
perldoc diagnostics.
Your system and mine seem to be counting lines differently too. Ah well.
> here's the errors:
> %> perl -w e2000.pl # invoke the script from command line
> Useless use of concatenation in void context at news.pm line 39.
> Useless use of concatenation in void context at news.pm line 39.
We don't have news.pm to know what's going wrong here. But diagnostics
say that:
(W void) You did something without a side effect in a context that does nothing
with the return value, such as a statement that doesn't return a value
from a block, or the left side of a scalar comma operator. Very often
this points not to stupidity on your part, but a failure of Perl to parse
your program the way you thought it would....[omitted, use diagnostics
in your program for more details]
You probably said something like:
$foo . 'bar';
As a bare statement somewhere in news.pm near line 39.
Is this program called e2000.pl? Your line numbers and mine don't match
up, so I have to guess.
> Global symbol "screen" requires explicit package name at e2000.pl line
> 152.
You have "strict" in effect (use strict) and @screen hasn't been declared with
my in that scope. (I think that's line 152...)
> Too many arguments for culture::dining at e2000.pl line 205, near "})
> "
> Too many arguments for culture::film at e2000.pl line 206, near "}) "
> Too many arguments for culture::music at e2000.pl line 207, near "}) "
> Too many arguments for culture::tv at e2000.pl line 208, near "}) "
> Execution of e2000.pl aborted due to compilation errors.
We don't have these modules to tell, but from the look of it someone used
a prototype and then lied about the argument count later. Most likely
someone said something like:
sub foo () {
}
Not knowing what those parens do (perl-style prototypes) and suffering from too
much JavaScript programming. See the perlsub manpage for details.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Tue, 5 Jun 2001 16:03:46 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Regex Question
Message-Id: <slrn9hqep2.346.tadmc@tadmc26.august.net>
Anova <c.leblanc4@sympatico.ca> wrote:
>
>I am working on a assignment and I need to write a Regular expression
>that meet the following criteria.
What work have you done towards your assignment?
Or do you just want others to do it for you?
read perlre.pod?
Tried any code? Let's see it, we will help you fix it.
Searched the Perl FAQ?
perldoc -q number
-------------------------------------------
How do I determine whether a scalar is a number/whole/integer/float?
Assuming that you don't care about IEEE notations like "NaN" or
"Infinity", you probably just want to use a regular expression.
if (/\D/) { print "has nondigits\n" }
if (/^\d+$/) { print "is a whole number\n" }
if (/^-?\d+$/) { print "is an integer\n" }
if (/^[+-]?\d+$/) { print "is a +/- integer\n" }
...
-------------------------------------------
>A floating point number consists of
s/A/A positive/; # I see no mention of a sign
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 5 Jun 2001 22:51:37 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Perl Regex Question
Message-Id: <slrn9hqojp.h5q.abigail@tsathoggua.rlyeh.net>
Arne Jamtgaard (ajamtgaa@cisco.com) wrote on MMDCCCXXXV September
MCMXCIII in <URL:news:3B1D56C3.7442F33D@cisco.com>:
== Anova wrote:
== >
== > Hello,
== >
== > I am working on a assignment and I need to write a Regular expression
== > that meet the following criteria.
== >
== > A floating point number consists of two non-empty strings of ASCII
== > digits separated with a period. The second string is optional. Leading
== > zeros are not allowed in the first string, that is, 01.0, 002.0, .0, .7
== > are examples of illegal constants; 0.0, 0.00, 0.010, 0., 1., 880. are
== > legal
== > constants.
==
== Just a point of clarification:
==
== You listed 0., 1., and 880. as 'legal', but above defined a floating
== point number as _two_ non-empty strings. Your examples look like
== the second is indeed empty, yet are called 'legal'.
But the next sentence says "The second string is optional.".
== Which is it?
Guess.
Now, if you want to pick nits, ask why "0." is legal if leading zeros
aren't allowed.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Tue, 5 Jun 2001 19:20:24 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Regex Question
Message-Id: <slrn9hqq9o.3k7.tadmc@tadmc26.august.net>
Abigail <abigail@foad.org> wrote:
>Arne Jamtgaard (ajamtgaa@cisco.com) wrote on MMDCCCXXXV September
>MCMXCIII in <URL:news:3B1D56C3.7442F33D@cisco.com>:
>== Anova wrote:
>== > I am working on a assignment and I need to write a Regular expression
>== > that meet the following criteria.
>== >
>== > A floating point number consists of two non-empty strings of ASCII
>== > digits separated with a period. The second string is optional. Leading
^^^^^^^^^
>== > zeros are not allowed in the first string, that is, 01.0, 002.0, .0, .7
>== > are examples of illegal constants; 0.0, 0.00, 0.010, 0., 1., 880. are
>== > legal
>== > constants.
>==
>== Just a point of clarification:
>==
>== You listed 0., 1., and 880. as 'legal', but above defined a floating
>== point number as _two_ non-empty strings. Your examples look like
>== the second is indeed empty, yet are called 'legal'.
>
>But the next sentence says "The second string is optional.".
But but, you don't include a separator when you don't have 2 things
to separate :-)
So
0
is OK, but
0.
is not OK.
>== Which is it?
>
>Guess.
I'm still guessing...
>Now, if you want to pick nits, ask why "0." is legal if leading zeros
>aren't allowed.
Why is there a separator when there aren't things to separate?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 5 Jun 2001 17:06:35 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Server Problems
Message-Id: <slrn9hqier.346.tadmc@tadmc26.august.net>
Joe <jbowman@budweiser.com> wrote:
>I am having a problem with a perl server.
There is no such thing as a "perl server" AFAIK, so you've lost me already.
>Basically I am trying to
>adapt a CGI
You seem to be doing a CGI application of Perl. That would be using
an "HTTP server" or a "web server".
>dealing with files that
>need to be input to it that are very large (my example file given to
>me is 42.9kb).
I suppose it depends on what you are used to, but I wouldn't call
50k "large" let alone "very large".
>The problem I am having is that on the large files, my variable
>$storytextsend is never getting cleared, even though I explicitly
>clear it in serveral places.
Show us a short and complete program that illustrates the problem.
At this point I can't even tell if you want $storytextsend to contain
zero characters, or if you are asking about getting back the memory
that $storytextsend uses.
>This is the variable that holds the
>largest amount of text in it.
>
>The full code for my server is listed below -
>
>------------------------------------------------------------------------------
>#!/usr/bin/perl
>##########################################################################
>#
># I/O Multiplexing Server example.
[snip 1200 lines of somebody else's code that won't even compile
because a word-wrapper has gotten ahold of the text and screwed
up the comments.
]
Please do not post 1200 line programs, it can have a negative effect
on your ability to get answers to Perl questions in the future.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 5 Jun 2001 22:52:57 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Perl Server Problems
Message-Id: <slrn9hqom9.h5q.abigail@tsathoggua.rlyeh.net>
Joe (jbowman@budweiser.com) wrote on MMDCCCXXXV September MCMXCIII in
<URL:news:6e9d82e3.0106050813.4d5f5ac@posting.google.com>:
[] I am having a problem with a perl server. Basically I am trying to
[] adapt a CGI I had written to a perl server which interacts with Java
[] Applet clients. The reason being is that I am dealing with files that
[] need to be input to it that are very large (my example file given to
[] me is 42.9kb).
[]
[] The problem I am having is that on the large files, my variable
[] $storytextsend is never getting cleared, even though I explicitly
[] clear it in serveral places. This is the variable that holds the
[] largest amount of text in it.
[]
[] The full code for my server is listed below -
[1286 lines deleted]
I think you have a bug in the code.
Abigail
--
split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
------------------------------
Date: 5 Jun 2001 15:17:55 -0700
From: m-m@lcc.net (GearGirl)
Subject: Re: Process form WITHOUT feedback page PART 2
Message-Id: <6f51e848.0106051417.31fdc1cb@posting.google.com>
nobull@mail.com wrote in message news:<u94rtu24jf.fsf@wcl-l.bham.ac.uk>...
> m-m@lcc.net (GearGirl) writes:
>
> > Subject: Process form WITHOUT feedback page PART 2
> ^^^^^^
>
> > As suggested I used the "Status: 204 No Response"
>
> It was also suggested that this had nothing whatever to do with Perl,
> and that you should therefore take this matter elsewhere. That you
> did. Why have you come back?
I have come back because I see NOTHING that indicates that this is not
Perl related. NOTHING. My first post was in
comp.infosystems.www.authoring.cgi
GET A GRIP.
> > now I'm getting a new browser window ANYWAY that is titled "No page
> > to display -- Microsoft Internet Explorer" and has an "Action
> > Canceled" message in it.
>
> That's kinda reasonable if you instruct your browser to display the
> outcome of an HTTP transation in a new browser window and that
> transaction yeilds "No Response".
>
> Once again I must point out since you evidently missed it the fist
> time, that this has nothing whatever in the slightest to do with Perl
> in any way whatsoever, and that you should therefore take this matter
> elsewhere.
What crawled up your butt and died?? I haven't seen you get this
pissy before. Your previous response (in the
comp.infosystems.www.authoring.cgi group, mind you) was as follows:
> m-m@lcc.net (GearGirl) writes:
>
> : I am trying to process a form's inputs WITHOUT giving a "thank you for your
> : submission..." feedback page.
> : I want to keep the user right where they are (perhaps similar to a
> : hidden hit counter???).
>
> Sounds to me like you are describing a 204 status in the HTTP
> response.
>
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
> --
> PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
> SELF-MODERATED newsgroup. aa.net and boutell.com are
> NOT the originators of the articles and are NOT responsible
> for their content.
IF there were any other posts, NONE of them show up in my NG file or
in GOOGLE's list. I tried unsuccessfully to post through my ISP
several times, and then the techs there told me that they are
configured as "read only" (no posting goes through), so I then tried
to post through GOOGLE, but my posts never showed up. The group skips
from April 9 to May 29. I cannot receive instructions or directions
from posts that I don't see!!!!
And I strongly believe this DOES have something to do with Perl, since
a Perl script is what I wrote to DO this. That's also why I'm posting
to a *.misc section, because it appears to be a catch-all.
My question remains, how do I keep from instructing the browser to
open another window. All I want to do is gather data from my site and
store it, and that's all.
~Melissa
------------------------------
Date: Tue, 05 Jun 2001 22:53:11 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Process form WITHOUT feedback page PART 2
Message-Id: <3b1d6027.83372782@news.erols.com>
On 5 Jun 2001 15:17:55 -0700, m-m@lcc.net (GearGirl) wrote:
>I have come back because I see NOTHING that indicates that this is not
>Perl related.
Logically, if it is a Perl problem, it can be corrected by modifying
the Perl code. Show the code.
------------------------------
Date: Tue, 05 Jun 2001 17:55:59 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Process form WITHOUT feedback page PART 2
Message-Id: <3B1D7F9F.AB657AFA@stomp.stomp.tokyo>
GearGirl wrote:
(snipped)
> As suggested, I used the "Status: 204 No Response" lines in my Perl
> script to try to capture some hidden info on one of my pages WITHOUT
> giving the user a feedback page, and now I'm getting a new browser
> window ANYWAY that is titled "No page to display -- Microsoft Internet
> Explorer" and has an "Action Canceled" message in it...
I have successfully replicated what you are doing. This
works perfect with Mozilla 4.7 although I understand your
problem is with Microsoft's browser. As you know MSIE does
not meet industry standards. Nonetheless, maybe you will
spot something in my html code and script code which
might be of help.
I do not have MSIE installed nor intend to install it.
As it is, I spend several hours removing MSIE from my
system, well, almost all components. Some cannot be
removed without Win 98 se crashing.
* curses Microsoft *
Godzilla!
--
This is my html page
____________________
<html><body>
<FORM ACTION="test1.cgi" METHOD="POST">
<INPUT TYPE="submit" NAME="Button" VALUE="204 Test">
<INPUT TYPE="hidden" NAME="Purl_Gurl" VALUE="purl_gurl">
</FORM>
</body></html>
This is test1.cgi
It does print to test.dat successfully
_________________
#!perl
&Akostininchi_Ithana;
sub Akostininchi_Ithana
{
local (*in) = @_ if @_;
local ($i, $key, $value);
read (STDIN, $in, $ENV{'CONTENT_LENGTH'});
@in = split (/&/, $in);
foreach $i (0 .. $#in)
{
$in[$i] =~ s/\+/ /g;
($key, $value) = split (/=/, $in[$i], 2);
($value eq "") && next;
$key =~ s/%(..)/pack ("c",hex($1))/ge;
$value =~ s/%(..)/pack ("c",hex($1))/ge;
$in{$key} .= "\0" if (defined ($in{$key}));
$in{$key} .= $value;
}
return 1;
}
open (TEST, ">test.dat");
print TEST $in{'Purl_Gurl'};
close (TEST);
print "Status: 204 No Response\n\n";
------------------------------
Date: 5 Jun 2001 16:38:01 -0700
From: char@wideeyed.com (Wide Eyed)
Subject: Setting cgi variable from form data
Message-Id: <564699e3.0106051538.42c8b3e5@posting.google.com>
I'd like to set a variable in a guestbook script to specify the page
the script writes the entry to according to a button checked on the
guestbook entry form.
The guestbook form has several different pushbutton fields with
different values, (i.e., Actors, Writers, PCTechs, etc). I have named
each of the fields "listingpage", and each has a different value
pointing to a web page (i.e., actors.htm, writers.htm, pctechs.htm,
etc.)
The variable in the guestbook script is named $listingpage
$listingpage plugs into the $guestbookurl variable to complete the
link to the correct page (i.e., $guestbookurl =
"http://www.domainname.com/$listingpage")
If I can get this to work, using the $guestbookurl example above, if
the user clicks on the pctech button on the form, the $guestbookurl
will change to "http://www.domainname.com/pctech.htm.
Can someone supply a snippet of code I can use to do this, or point me
in the right direction to find out how to do it?
Thanks so much for your time.
------------------------------
Date: Tue, 05 Jun 2001 19:47:25 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: Setting cgi variable from form data
Message-Id: <3B1CF0FD.737498C4@ce.gatech.edu>
Wide Eyed wrote:
> I'd like to set a variable in a guestbook script to specify the page
> the script writes the entry to according to a button checked on the
> guestbook entry form.
>
> The guestbook form has several different pushbutton fields with
> different values, (i.e., Actors, Writers, PCTechs, etc). I have named
> each of the fields "listingpage", and each has a different value
> pointing to a web page (i.e., actors.htm, writers.htm, pctechs.htm,
> etc.)
>
> The variable in the guestbook script is named $listingpage
>
> $listingpage plugs into the $guestbookurl variable to complete the
> link to the correct page (i.e., $guestbookurl =
> "http://www.domainname.com/$listingpage")
>
> If I can get this to work, using the $guestbookurl example above, if
> the user clicks on the pctech button on the form, the $guestbookurl
> will change to "http://www.domainname.com/pctech.htm.
>
> Can someone supply a snippet of code I can use to do this, or point me
> in the right direction to find out how to do it?
>
> Thanks so much for your time.
if you are using CGI.pm:
$listingpage = $q->param('listingpage');
------------------------------
Date: Wed, 6 Jun 2001 00:30:53 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Setting cgi variable from form data
Message-Id: <slrn9hqudt.2ot.see-sig@typhoon.xnet.com>
On 5 Jun 2001 16:38:01 -0700, Wide Eyed <char@wideeyed.com> wrote:
> I'd like to set a variable in a guestbook script to specify the page
> the script writes the entry to according to a button checked on the
> guestbook entry form.
>
> The guestbook form has several different pushbutton fields with
> different values, (i.e., Actors, Writers, PCTechs, etc). I have named
> each of the fields "listingpage", and each has a different value
> pointing to a web page (i.e., actors.htm, writers.htm, pctechs.htm,
> etc.)
>
> The variable in the guestbook script is named $listingpage
>
> $listingpage plugs into the $guestbookurl variable to complete the
> link to the correct page (i.e., $guestbookurl =
> "http://www.domainname.com/$listingpage")
>
> If I can get this to work, using the $guestbookurl example above, if
> the user clicks on the pctech button on the form, the $guestbookurl
> will change to "http://www.domainname.com/pctech.htm.
>
> Can someone supply a snippet of code I can use to do this, or point me
> in the right direction to find out how to do it?
The *.cgi newsgroup perhaps. But here is an example of simple form and
processing that prints an example of such a link. Note that lc() changes
the selected mixed case radio button label/value to lower case:
#!/usr/bin/perl -w
use CGI qw/:standard/;
print header,start_html('Page Title'),h1('Test'),hr;
if (param) {
$listingpage = lc(param('listingpage')) . ".htm";
print a({href=>"http://www.domainname.com/$listingpage"},
$listingpage),p;
}
print start_form,'Pick One:',br,radio_group('listingpage',
['Actors','Writers','PCTechs'],undef,'true'),p,
submit(undef,'Test'),end_form,end_html;
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 05 Jun 2001 18:26:50 -0400
From: Lex Spoon <lex@cc.gatech.edu>
Subject: Re: The FlakeyMind/Bryce Jacobs FAQ (v0.1)
Message-Id: <m3snheef5r.fsf@chaos.resnet.gatech.edu>
I think the best strategy on USENET is to steel yourself and assume
that the readers whose opinions you care about will be able to decide
which responses are legit and which are bogus. Let's not worry about
defaming people explicitly; hopefully the people whose opinions we
care about, can see that the people we hate are as dumb as we think
they are.
Lex
------------------------------
Date: Tue, 05 Jun 2001 22:37:20 GMT
From: "Kenneth Eide" <js@hotmail.com>
Subject: Trying to create and "upload" field an print out the contents of the file to the browser
Message-Id: <AadT6.5657$qR5.425804@news01.chello.no>
Hello, this script won't work.. do anyone of you see what the error is?
#!/usr/bin/perl -w
use CGI;
use strict;
my $q = new CGI;
print $q->header;
print $q->start_html("..savetest");
print "<H1> SAVE TEST</H1>\n";
print $q->startform;
print $q->filefield(-name=>'uploaded_file');
print "<P>";
print $q->submit('action','save');
print $q->endform;
if ($q->param()){
print "<P>Contents of file:<P>";
my $filename = $q->param('uploaded_file');
while (<$filename>) {
print;
}
}
print $q->end_html;
The help I've gotten to write this script is from:
http://search.cpan.org/doc/LDS/CGI.pm-2.753/CGI.pm
Search for "FILE UPLOAD FIELD" to get to the right place
Any help would be appriciated, thanks!
Sincerely
Kenneth Edide
------------------------------
Date: Tue, 5 Jun 2001 20:23:14 -0400
From: "Todd W" <trw@uakron.edu>
Subject: Re: Trying to create and "upload" field an print out the contents of the file to the browser
Message-Id: <9fjt64$orb$1@kira.cc.uakron.edu>
Kenneth Eide <js@hotmail.com> wrote in message
news:AadT6.5657$qR5.425804@news01.chello.no...
> Hello, this script won't work.. do anyone of you see what the error is?
... code snipped ...
1. CGI doc: filefield() will return a file upload field for Netscape 2.0
browsers. In order to take full advantage of this you must use the new
multipart encoding scheme for the form. You can do this either by calling
start_form() with an encoding type of &CGI::MULTIPART, or by calling the new
method start_multipart_form() instead of vanilla start_form().
so i would probably use the start_multipart_form() method right off
2. CGI doc: To be safe, use the upload() function (new in version 2.47).
When called with the name of an upload field, upload() returns a filehandle,
or undef if the parameter is not a valid filehandle.
$fh = $query->upload('uploaded_file');
while (<$fh>) {
print;
}
In an array context, upload() will return an array of filehandles. This
makes it possible to create forms that use the same name for multiple upload
fields.
This is the recommended idiom.
so I would use the upload() method instead of the param() method
3. CGI doc: There are occasionally problems involving parsing the uploaded
file. This usually happens when the user presses "Stop" before the upload is
finished. In this case, CGI.pm will return undef for the name of the
uploaded file and set cgi_error() to the string "400 Bad request (malformed
multipart POST)". This error message is designed so that you can incorporate
it into a status code to be sent to the browser.
so (espically) while developing, i would at least print the return value of
that method out
tw
------------------------------
Date: Wed, 6 Jun 2001 00:57:52 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: using CGI and CGI::Cookie at the same time
Message-Id: <slrn9hr00f.2ot.see-sig@typhoon.xnet.com>
On Tue, 05 Jun 2001 18:45:17 GMT, Todd Smith <todd@designsouth.net> wrote:
> Here's my problem: If I use CGI and CGI::Cookie at the same time, I can't
> get a CGI object to work.
CGI.pm includes cookie creation and handling routines. What do you need
from CGI::Cookie that is not already included in CGI.pm?
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Tue, 5 Jun 2001 16:38:22 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: What am I doing wrong with this array operation?
Message-Id: <slrn9hqgpu.346.tadmc@tadmc26.august.net>
Andrew J. Perrin <aperrin@telocity.com> wrote:
>"Jason C. Hill" <jhill@technoslave.net> writes:
>
>> I have several lines of input that I push in to an array.
>>
>> @arr = join(':', split( /\s+/, $lines));
>
>I strongly suspect that your $lines is read in from a file (right?)
>and therefore has the \n (newlines) still on the end of each
>line. That's why you get the newlines in your output.
^^^^^^^^^^^^^^^^^^^^^^^
That cannot be it.
Note the split pattern, no newlines are going to make it into @arr.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 5 Jun 2001 16:42:08 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: What am I doing wrong with this array operation?
Message-Id: <slrn9hqh10.346.tadmc@tadmc26.august.net>
[ Please put your comments *following* the quoted text that you
are commenting on.
Thanks.
Lines rearranged into normal chronology.
]
Jason C. Hill <jhill@technoslave.net> wrote:
>In article <87vgma6d1x.fsf@nujoma.perrins>, "Andrew J. Perrin"
><aperrin@telocity.com> wrote:
>> "Jason C. Hill" <jhill@technoslave.net> writes:
>>
>>> I have several lines of input that I push in to an array.
>>>
>>> @arr = join(':', split( /\s+/, $lines));
>As to my input...most of the time it looks like this
>
>get_headends 1 . . . .100 . . .
>get_index 3 . . . . 33 . . 33 33
>
>Anyway, the program that creates these nice little useless figures is
>called stag. And even though the above output doesn't look like, due to
>fonts (on my end at least), they're all equally spaced.
^^^^^^^^^^^^^^
Then split() is not the Right Tool For the Job.
Use unpack() or substr() for fixed-width fields.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 5 Jun 2001 16:43:31 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: What am I doing wrong with this array operation?
Message-Id: <slrn9hqh3j.346.tadmc@tadmc26.august.net>
Jason C. Hill <jhill@technoslave.net> wrote:
>I just typed it
Please do not try and retype code in postings.
Use copy/paste, or import, or something, else you'll just get a
bunch of wise ass comments about your typos instead of about
your real problem.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 05 Jun 2001 16:51:50 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: What am I doing wrong with this array operation?
Message-Id: <m3snhetx1l.fsf@dhcp9-173.support.tivoli.com>
On Tue, 05 Jun 2001, jhill@technoslave.net wrote:
> I have several lines of input that I push in to an array.
>
> @arr = join(':', split( /\s+/, $lines));
That split on "\s+" is going to remove the newlines.
> Output looks something similiar to
>
> operation:123456:123:.:.:.:33:33:33:1:.
> operation2:23456:12:.:.:24:26:.:50:1:.:1
> operation3:19472:12747:.:10:39:1:60:.:.:.:.
> operation4:1237:13:29:31:20:.:.:.:.:10:10:.
>
> Despite the above, they're all exact length entries...(I believe
> there are 22 or 23 total).
>
> Anyway, when I do a print "@arr"; it prints everything out in a nice
> line by line, as above.
Not with that split. Perhaps if you split on " +".
> However, there's a possible entry in to the data that I need to
> account for. Namely, the entry '.100'
In a subsequent post you gave the input format, where you show that
the input data is in what looks to be a fixed with format. You may
find treating it as such and then stripping of the extra spaces to be
an easier way to handle it. You could use unpack to pull apart the
fields pretty easily.
> So, I do this:
>
> foreach my $item (@arr) {
> if ($item !~ /\.100/) {
> push (@temp, "$item");
> } else {
> push (@temp, ".");
> push (@temp, "100");
> }
>
> @arr = @temp;
>
> Then when I do a print "@arr"; it comes out with no newline like
> above..So it would look something like this:
>
> operation:123456:123:.:.:.:33:33:33:1:. operation2:23456:12:.:.:
> 24:26:.:50:1:.:1operation3:19472:12747:.:10:39:1:60:.:.:.:. operation4:
> 1237:13:29:31:20:.:.:.:.:10:10:.
>
> Etc, no new line at the end. I would guess it has something to do
> with pushing the item to the new array. But I'm not quite sure.
> Doing a print "@arr\n"; has no effect.
>
> What is it that I'm doing wrong here?
Not the push, but the split. Assuming you don't go with the alternate
solution I've proposed, but do fix the split (perhaps using " +"
instead of "\s+"), then you might need to handle the possibility of
the newline being on the ".100" piece. So rather than pushing a
literal "." and "100", how about something like:
if ($item =~ /\.\d/) { # period and digit is really two fields
push @temp, "."; # push the period on the array
$item =~ s/^\.//; # and remove it from this item
}
push @temp, $item; # push the item on the array
Another approach might be something like:
$lines =~ s/ +/:/g;
$lines =~ s/\.(\d)/.:$1/g;
Those two lines should convert all the data without needing to split
it apart at all.
--
Ren Maddox
ren@tivoli.com
------------------------------
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 1068
***************************************