[25353] in Perl-Users-Digest
Perl-Users Digest, Issue: 7595 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 3 21:53:36 2005
Date: Mon, 3 Jan 2005 15:11:44 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 3 Jan 2005 Volume: 10 Number: 7595
Today's topics:
CGI.pm and special characters in hidden inputs tsunami@zedxinc.com
Re: CGI.pm and special characters in hidden inputs <flavell@ph.gla.ac.uk>
Re: CGI.pm and special characters in hidden inputs ioneabu@yahoo.com
Re: CGI.pm and special characters in hidden inputs <noreply@gunnar.cc>
Re: CGI.pm and special characters in hidden inputs <noreply@gunnar.cc>
Re: CGI.pm and special characters in hidden inputs <matthew.garrish@sympatico.ca>
Re: CGI.pm and special characters in hidden inputs ioneabu@yahoo.com
Re: CGI.pm and special characters in hidden inputs <noreply@gunnar.cc>
Re: CGI.pm and special characters in hidden inputs <noreply@gunnar.cc>
Re: CGI.pm and special characters in hidden inputs <noreply@gunnar.cc>
Re: CGI.pm and special characters in hidden inputs <matthew.garrish@sympatico.ca>
Re: CGI.pm and special characters in hidden inputs <matthew.garrish@sympatico.ca>
Re: CGI.pm and special characters in hidden inputs <wyzelli@yahoo.com>
Re: charting data <jgibson@mail.arc.nasa.gov>
Re: charting data <zebee@zip.com.au>
Re: charting data <jgibson@mail.arc.nasa.gov>
Re: close() or die xhoster@gmail.com
Re: Construct listbox with CGI <jgibson@mail.arc.nasa.gov>
Curses and getch problem spambox@volja.net
DBD/DBI failing to add a blank in a non-null field <dn_perl@hotmail.com>
Re: DBD/DBI failing to add a blank in a non-null field <matthew.garrish@sympatico.ca>
Re: FAQ 1.9: How does Perl compare with other languages <gmeazell@swbell.net>
Function returns into a Scalar <nospam@nospam.com>
Re: Function returns into a Scalar <matthew.garrish@sympatico.ca>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Dec 2004 14:54:17 -0800
From: tsunami@zedxinc.com
Subject: CGI.pm and special characters in hidden inputs
Message-Id: <1104360857.764399.141920@c13g2000cwb.googlegroups.com>
Hello,
I use CGI.pm to parse forms, and I am running into issues with certain
special characters.
Say I have a form element, with a value of "Mom's House". It is a
hidden input, passed in from a previous page, so the HTML is something
like this:
<INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
I was given to understand that, for ' " > < and &, you need to use the
encoded value to denote the character when it appears in a tag. I know
this is the case for normal XML files, and the parsers take care of it.
However, CGI.pm's param() function does NOT seem to be interpreting
the special characters. In the CGI script that processes this form, I
would have:
$location = param('location');
and $location would be: "Mom's House" While I could, in this
instance, simply NOT encode the apostrophe and it would probably work,
if it were a double quote, I know it would break it. Any ideas?
Thanks!
--
Dave
------------------------------
Date: Wed, 29 Dec 2004 23:17:57 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <Pine.LNX.4.61.0412292307260.17005@ppepc56.ph.gla.ac.uk>
On Wed, 29 Dec 2004 tsunami@zedxinc.com wrote:
> I use CGI.pm to parse forms, and I am running into issues
However, you don't appear to have a Perl problem...
> with certain special characters.
I'm afraid you've triggered a raw nerve there. Considering the many
thousands of Unicode characters which have been defined, what you you
suppose is so "special" about a us-ascii apostrophe?
> Say I have a form element, with a value of "Mom's House". It is a
> hidden input, passed in from a previous page, so the HTML is
> something like this:
>
> <INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
Could be...
> I was given to understand that, for ' " > < and &, you need to use
> the encoded value to denote the character when it appears in a tag.
Not exactly - for details consult a group with comp.infosystems.www...
in its name. But that's irrelevant, because the client agent has to
parse that. So it makes no difference which of the ways you choose to
represent your characters in the HTML source (the coded character
itself, its numerical character reference, or its character entity).
At submission time they're all the same.
> However, CGI.pm's param() function does NOT seem to be interpreting
> the special characters.
What do you mean by "interpreting"?
> In the CGI script that processes this form, I would have:
>
> $location = param('location');
>
> and $location would be: "Mom's House"
It would??? Let's have a URL which demonstrates this behaviour!
But you're off-topic here. You'd be better on a WWW authoring group
(namely, comp.infosystems.www.authoring.cgi, but beware its
automoderation bot).
------------------------------
Date: 29 Dec 2004 15:21:23 -0800
From: ioneabu@yahoo.com
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <1104362483.851503.32240@z14g2000cwz.googlegroups.com>
tsunami@zedxinc.com wrote:
> Hello,
>
> I use CGI.pm to parse forms, and I am running into issues with
certain
> special characters.
>
> Say I have a form element, with a value of "Mom's House". It is a
> hidden input, passed in from a previous page, so the HTML is
something
> like this:
>
> <INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
print hidden(-name=>'location', -value=>"Mom's House");
Should work fine if you use CGI.pm like this.
>
> I was given to understand that, for ' " > < and &, you need to use
the
> encoded value to denote the character when it appears in a tag. I
know
> this is the case for normal XML files, and the parsers take care of
it.
> However, CGI.pm's param() function does NOT seem to be interpreting
> the special characters. In the CGI script that processes this form,
I
> would have:
>
> $location = param('location');
>
> and $location would be: "Mom's House" While I could, in this
> instance, simply NOT encode the apostrophe and it would probably
work,
> if it were a double quote, I know it would break it. Any ideas?
> Thanks!
>
>From CGI.pm home page: http://stein.cshl.org/WWW/software/CGI/
<quote>
AUTOESCAPING HTML
By default, all HTML that are emitted by the form-generating functions
are passed through a function called escapeHTML():
$escaped_string = escapeHTML("unescaped string");
Provided that you have specified a character set of ISO-8859-1 (the
default), the standard HTML escaping rules will be used. The "<"
character becomes "<", ">" becomes ">", "&" becomes "&", and
the quote character becomes """. In addition, the hexadecimal 0x8b
and 0x9b characters, which many windows-based browsers interpret as the
left and right angle-bracket characters, are replaced by their numeric
HTML entities ("‹" and "›"). If you manually change the
charset, either by calling the charset() method explicitly or by
passing a -charset argument to header(), then all characters will be
replaced by their numeric entities, since CGI.pm has no lookup table
for all the possible encodings.
Autoescaping does not apply to other HTML-generating functions, such as
h1(). You should call escapeHTML() yourself on any data that is passed
in from the outside, such as nasty text that people may enter into
guestbooks.
To change the character set, use charset(). To turn autoescaping off
completely, use autoescape():
$charset = charset([$charset]); # Get or set the current character
set.
$flag = autoEscape([$flag]); # Get or set the value of the
autoescape flag.
</quote>
Hope this helps.
wana
------------------------------
Date: Thu, 30 Dec 2004 01:07:47 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <33gv4vF401lgnU1@individual.net>
tsunami@zedxinc.com wrote:
> <INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
<snip>
> In the CGI script that processes this form, I would have:
>
> $location = param('location');
>
> and $location would be: "Mom's House"
No, it wouldn't. Before submission, that character entity would be
converted by the browser to "'", so you don't have the problem you think
you have. Try and see for yourself!
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 30 Dec 2004 01:25:41 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <33h077F3vrmccU1@individual.net>
ioneabu@yahoo.com wrote:
> tsunami@zedxinc.com wrote:
>> <INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
<snip>
>> In the CGI script that processes this form, I would have:
>>
>> $location = param('location');
>>
>> and $location would be: "Mom's House"
>
> From CGI.pm home page: http://stein.cshl.org/WWW/software/CGI/
>
> <quote>
> AUTOESCAPING HTML
<snip>
> </quote>
In what way is that quote related to the OP's concern?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 29 Dec 2004 19:33:28 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <p1IAd.26024$nV.880232@news20.bellglobal.com>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:33gv4vF401lgnU1@individual.net...
> tsunami@zedxinc.com wrote:
>> <INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
>
> <snip>
>
>> In the CGI script that processes this form, I would have:
>>
>> $location = param('location');
>>
>> and $location would be: "Mom's House"
>
> No, it wouldn't. Before submission, that character entity would be
> converted by the browser to "'", so you don't have the problem you think
> you have. Try and see for yourself!
>
Huh? Did you test that yourself? I've never heard of a browser converting
entities in a hidden form field.
test.htm
------------------------------
<html>
<head>
<title></title>
</head>
<body>
<form name="test" action="/cgi-bin/test.cgi" method="post">
<input type="hidden" name="location" value="what's wrong with this?" />
<input type="submit" />
</form>
</body>
</html>
test.cgi
------------------
use CGI qw/param/;
my $location = param('location');
print "Content-type: text/plain\n\n";
print $location;
Output:
--------------------
what's wrong with this?
Matt
------------------------------
Date: 29 Dec 2004 16:52:19 -0800
From: ioneabu@yahoo.com
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <1104367939.764224.257990@f14g2000cwb.googlegroups.com>
>
> In what way is that quote related to the OP's concern?
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
For example, I put this in my Perl program using CGI.pm:
print textfield({name=>'Name', value=>"bob's"});
When I view source in my browser it looks like this:
<input type="text" name="Name" value="bob's" />
CGI.pm handled the HTML escaping automatically as promised in the
section I quoted. I think that's what he was asking about.
wana
------------------------------
Date: Thu, 30 Dec 2004 03:14:15 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <33h6n8F3t1li6U1@individual.net>
Matt Garrish wrote:
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> news:33gv4vF401lgnU1@individual.net...
>>tsunami@zedxinc.com wrote:
>>>
>>><INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
>>
>><snip>
>>
>>>In the CGI script that processes this form, I would have:
>>>
>>>$location = param('location');
>>>
>>>and $location would be: "Mom's House"
>>
>>No, it wouldn't. Before submission, that character entity would be
>>converted by the browser to "'", so you don't have the problem you think
>>you have. Try and see for yourself!
>
> Huh? Did you test that yourself?
No.
> I've never heard of a browser converting entities in a hidden form field.
<example code snipped>
> Output:
> --------------------
> what's wrong with this?
When running your code, I get:
what's wrong with this?
Hmm.. Guess Alan has to clarify again. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 30 Dec 2004 03:14:32 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <33h6noF3t1li6U2@individual.net>
ioneabu@yahoo.com wrote:
>>In what way is that quote related to the OP's concern?
>
> For example, I put this in my Perl program using CGI.pm:
>
> print textfield({name=>'Name', value=>"bob's"});
>
> When I view source in my browser it looks like this:
>
> <input type="text" name="Name" value="bob's" />
>
> CGI.pm handled the HTML escaping automatically as promised in the
> section I quoted. I think that's what he was asking about.
CGI.pm converted the ' character to a character entity.
The OP had already a character entity, and I think he was asking about
how to get the original character back.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 30 Dec 2004 04:25:24 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <33havtF3vlf7aU1@individual.net>
Gunnar Hjalmarsson wrote:
> tsunami@zedxinc.com wrote:
>>
>> <INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
>
> <snip>
>
>> In the CGI script that processes this form, I would have:
>>
>> $location = param('location');
>>
>> and $location would be: "Mom's House"
>
> No, it wouldn't. Before submission, that character entity would be
> converted by the browser to "'", so you don't have the problem you think
> you have. Try and see for yourself!
Matt's objection made me do some testing, and Firefox understands
"'", while MSIE does not, which explains the confusion. (MSIE does
understand the other: """, "<", ">" and "&".)
So use the entity number "'" instead of "'" to avoid problems.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 29 Dec 2004 22:53:32 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <_YKAd.32035$Tn1.1345695@news20.bellglobal.com>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:33h6n8F3t1li6U1@individual.net...
> Matt Garrish wrote:
>> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
>> news:33gv4vF401lgnU1@individual.net...
>>>tsunami@zedxinc.com wrote:
>>>>
>>>><INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
>>>
>>><snip>
>>>
>>>>In the CGI script that processes this form, I would have:
>>>>
>>>>$location = param('location');
>>>>
>>>>and $location would be: "Mom's House"
>>>
>>>No, it wouldn't. Before submission, that character entity would be
>>>converted by the browser to "'", so you don't have the problem you think
>>>you have. Try and see for yourself!
>>
>> Huh? Did you test that yourself?
>
> No.
>
>> I've never heard of a browser converting entities in a hidden form field.
>
> <example code snipped>
>
>> Output:
>> --------------------
>> what's wrong with this?
>
> When running your code, I get:
> what's wrong with this?
>
> Hmm.. Guess Alan has to clarify again. :)
>
Something I've never considered before, if that is the case (not that I
spend a lot of time with web forms). I can see some benefit in automatically
converting the entities, however I don't think I'd ever want a browser
making that decision for me.
I'll see if I can find an explanation of this behaviour, even if it is
getting off topic...
Matt
------------------------------
Date: Thu, 30 Dec 2004 00:01:47 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <YYLAd.32072$Tn1.1368561@news20.bellglobal.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:_YKAd.32035$Tn1.1345695@news20.bellglobal.com...
>
> I'll see if I can find an explanation of this behaviour, even if it is
> getting off topic...
>
Alas, Google has let me down (or I can't find the right combination of
terms, at least). I still can't see much benefit in translating the entities
back to characters automatically when the form is submitted. The only
advantage would seem to be that it means transferring slightly less data on
the form submission. I suspect it has something to do with the attempts to
render entities as characters within visible form fields, but I would have
thought the hidden input type's value would be more along the lines of a
single-quoted string in Perl.
If someone has an official version of this behaviour, however, I'd be
interested in hearing what it is.
Matt
------------------------------
Date: Thu, 30 Dec 2004 08:05:04 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: CGI.pm and special characters in hidden inputs
Message-Id: <QEOAd.95539$K7.62247@news-server.bigpond.net.au>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:33havtF3vlf7aU1@individual.net...
: Gunnar Hjalmarsson wrote:
: > tsunami@zedxinc.com wrote:
: >>
: >> <INPUT TYPE="hidden" NAME="location" VALUE="Mom's House">
: >
: > <snip>
: >
: >> In the CGI script that processes this form, I would have:
: >>
: >> $location = param('location');
: >>
: >> and $location would be: "Mom's House"
: >
: > No, it wouldn't. Before submission, that character entity would be
: > converted by the browser to "'", so you don't have the problem you think
: > you have. Try and see for yourself!
:
: Matt's objection made me do some testing, and Firefox understands
: "'", while MSIE does not, which explains the confusion. (MSIE does
: understand the other: """, "<", ">" and "&".)
:
: So use the entity number "'" instead of "'" to avoid problems.
Or, given that it's a hidden field, change its name to something which
avoids special characters, and only use those where you need to deal with
displays.
--
Wyzelli
------------------------------
Date: Wed, 29 Dec 2004 10:08:20 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: charting data
Message-Id: <291220041008208235%jgibson@mail.arc.nasa.gov>
In article <slrnct4vgv.9dl.zebee@zeus.zipworld.com.au>, Zebee Johnstone
<zebee@zip.com.au> wrote:
> I have several - 3 to 20 - sets of data. Each has the same x-axis and
> y-axis bounds. Each consists of the x axis - time - and a y axis between
> 80 and 180 with 2 sets of data, a max and an average, to be plotted.
I usually use gnuplot for tasks like this, oftentimes with data
generated by perl and under the control of a perl program. It will also
generate PNG plot files which could be loaded into a web page.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Wed, 29 Dec 2004 20:17:18 GMT
From: Zebee Johnstone <zebee@zip.com.au>
Subject: Re: charting data
Message-Id: <slrnct63vu.v8o.zebee@zeus.zipworld.com.au>
In comp.lang.perl.misc on Wed, 29 Dec 2004 10:08:20 -0800
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> In article <slrnct4vgv.9dl.zebee@zeus.zipworld.com.au>, Zebee Johnstone
><zebee@zip.com.au> wrote:
>
>> I have several - 3 to 20 - sets of data. Each has the same x-axis and
>> y-axis bounds. Each consists of the x axis - time - and a y axis between
>> 80 and 180 with 2 sets of data, a max and an average, to be plotted.
>
> I usually use gnuplot for tasks like this, oftentimes with data
> generated by perl and under the control of a perl program. It will also
> generate PNG plot files which could be loaded into a web page.
>
But how to get gnuplot to generate data that is similar values but
plotted so they don't overlay?
Zebee
------------------------------
Date: Wed, 29 Dec 2004 13:24:03 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: charting data
Message-Id: <291220041324036250%jgibson@mail.arc.nasa.gov>
In article <slrnct63vu.v8o.zebee@zeus.zipworld.com.au>, Zebee Johnstone
<zebee@zip.com.au> wrote:
> In comp.lang.perl.misc on Wed, 29 Dec 2004 10:08:20 -0800
> Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> > In article <slrnct4vgv.9dl.zebee@zeus.zipworld.com.au>, Zebee Johnstone
> ><zebee@zip.com.au> wrote:
> >
> >> I have several - 3 to 20 - sets of data. Each has the same x-axis and
> >> y-axis bounds. Each consists of the x axis - time - and a y axis between
> >> 80 and 180 with 2 sets of data, a max and an average, to be plotted.
> >
> > I usually use gnuplot for tasks like this, oftentimes with data
> > generated by perl and under the control of a perl program. It will also
> > generate PNG plot files which could be loaded into a web page.
> >
>
> But how to get gnuplot to generate data that is similar values but
> plotted so they don't overlay?
>
> Zebee
Use the 'set multiplot' command along with 'set size' and 'set origin'
commands to place multiple plots above or beside each other. Please see
<http://www.gnuplot.info> for more information.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: 03 Jan 2005 17:57:40 GMT
From: xhoster@gmail.com
Subject: Re: close() or die
Message-Id: <20050103125740.877$hR@newsreader.com>
John Bokma <postmaster@castleamber.com> wrote:
> Recently a customer reported that a Perl script I had written suddenly
> reported an error.
>
> It turned out that it failed on the close (it died and reported that the
> close failed after writing to the file).
>
> It turned out that his disk quota had exceeded. So it seems that the
> close flushed the buffer, which failed, and my script nicely reported
> this.
>
> Bottomline: check your close. Without this it would have not been
> obvious.
> Even if I use auto-vivication, I close explicitly.
Also, if you use a pipe-open, some errors are only detected on close.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 03 Jan 2005 10:56:04 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Construct listbox with CGI
Message-Id: <030120051056042403%jgibson@mail.arc.nasa.gov>
In article <guSAd.14584$fe5.10437@trndny06>, Paul Lalli
<mritty@gmail.com> wrote:
[good advice snipped]
> > my @values;
> > my @lables;
> > my $i;
> > for ($i=0; $aref = $sth->fetchrow_arrayref; $i++){
> > $values[$i] = $aref->[0]; #custcode
> > $labels[$i] = $aref->[1]; #custname
> > }
> >
> > print $query->scrolling_list(
> > -NAME => "Outlets",
> > -VALUES => [@values],
> > -LABELS => \%labels,
> > -SIZE => 9,
> > -MULTIPLE => 1,
> > );
> > How can I fix this error?
>
> You define an array called @labels, you assign to that array, and then
Actually, he defines an array called @lables. This also would have been
revealed if the OP had used 'use strict'.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: 3 Jan 2005 09:05:34 -0800
From: spambox@volja.net
Subject: Curses and getch problem
Message-Id: <1104771934.489276.105910@f14g2000cwb.googlegroups.com>
Hello,
I'm experiencing problems with getch() from Curses. If I want to proces
standard input first with <>, takes all cpu time for, as it seems,
nothing except looping. Here is an example:
#!/usr/bin/perl
use Curses;
1 while <>;
initscr();
while (1) {
if (getch() eq 'q') {
endwin();
exit;
}
}
If you run it like "script.pl < somefile", pressing 'q' doesn't do
anything, whereas if you run it like "script.pl somefile", it works as
expected.
Ideas? Thanks,
andrej
------------------------------
Date: 29 Dec 2004 16:49:01 -0800
From: "dn_perl@hotmail.com" <dn_perl@hotmail.com>
Subject: DBD/DBI failing to add a blank in a non-null field
Message-Id: <1104367741.513616.310700@c13g2000cwb.googlegroups.com>
I am running into a problem with inserting a blank (not null) in a
non-null field via a placeholder.
sqlplus> desc mytable
fld01 not null varchar2(16) .
In Perl code :
use strict;
use DBI ;
my $dbh ; # DBI-> connect has been used to set value of $dbh
# database is Oracle 9i on solaris
my $user_id = ' ' ; # single space char in the string
my $dst = $dbh->prepare(" insert into
mytable (fld01) values(? ) " );
$dst->execute( $user_id ) or die "sql call failed." ;
---------------
But I get a DBD error that a null value cannot be entered into fld01. I
set $user_id to single-blank to insert a non-null value into
mytable.fld01 .
How can I add one space to mytable.fld01 ?
TIA.
------------------------------
Date: Wed, 29 Dec 2004 20:37:58 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: DBD/DBI failing to add a blank in a non-null field
Message-Id: <SZIAd.26058$nV.895728@news20.bellglobal.com>
<dn_perl@hotmail.com> wrote in message
news:1104367741.513616.310700@c13g2000cwb.googlegroups.com...
>
> I am running into a problem with inserting a blank (not null) in a
> non-null field via a placeholder.
>
> sqlplus> desc mytable
> fld01 not null varchar2(16) .
>
>
> In Perl code :
>
> use strict;
> use DBI ;
>
> my $dbh ; # DBI-> connect has been used to set value of $dbh
> # database is Oracle 9i on solaris
> my $user_id = ' ' ; # single space char in the string
> my $dst = $dbh->prepare(" insert into
> mytable (fld01) values(? ) " );
> $dst->execute( $user_id ) or die "sql call failed." ;
> ---------------
>
Oracle will strip the trailing spaces from the entry if it's a varchar
field, effectively leaving the entry null. See the documentation for the way
around this (ora_ph_type):
http://search.cpan.org/~timb/DBD-Oracle-1.16/Oracle.pm#Database_Handle_Attributes
Matt
------------------------------
Date: Wed, 29 Dec 2004 22:47:06 GMT
From: Gerald Meazell <gmeazell@swbell.net>
Subject: Re: FAQ 1.9: How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?
Message-Id: <KtGAd.4154$F67.335@newssvr12.news.prodigy.com>
PerlFAQ Server wrote:
> 1.9: How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?
>
> Favorably in some areas, unfavorably in others. Precisely which areas
> are good and bad is often a personal choice, so asking this question on
> Usenet runs a strong risk of starting an unproductive Holy War.
I'm just getting started with Perl but have extensive knowledge of REXX.
If you'd like me to write a comparison, I'd be happy to do that. Let
me know.
--
Gerald
------------------------------
Date: Thu, 30 Dec 2004 00:25:42 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Function returns into a Scalar
Message-Id: <1104384332.662210@nntp.acecape.com>
Hi all,
Not sure what the term is, but I would like to include the return value of a
function by assigning it into a string scalar. Can't find it in my two
books, nor can I find the proper keywords for perldoc. Below is a quick
script that has the non-working line uncommented.
Obviously using the "." isn't too bad, but when building a more complex
string, would be easier if I could do it all within a single set of quotes..
Thanks aheaad,
Daniel
#!/usr/bin/perl
use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
my $cTestvar;
#$cTestvar = "The value " . $q->param('pass') ." was passed in...";
$cTestvar = "The value $q->param('pass') was passed in...";
print $q->header();
print $cTestvar;
exit 0;
------------------------------
Date: Thu, 30 Dec 2004 01:12:09 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Function returns into a Scalar
Message-Id: <U_MAd.26205$nV.957015@news20.bellglobal.com>
"daniel kaplan" <nospam@nospam.com> wrote in message
news:1104384332.662210@nntp.acecape.com...
> Hi all,
>
> Not sure what the term is, but I would like to include the return value of
> a
> function by assigning it into a string scalar. Can't find it in my two
> books, nor can I find the proper keywords for perldoc. Below is a quick
> script that has the non-working line uncommented.
>
> #$cTestvar = "The value " . $q->param('pass') ." was passed in...";
> $cTestvar = "The value $q->param('pass') was passed in...";
>
>
It's called interpolation, and it can only be done with scalar values, not
with function calls (even if your function happens to return a scalar
value). If what you were asking for were possible, you'd have to comment out
every opening parenthesis in double quotes, not to mention that calling
functions within strings would just make for ugly coding.
What particular reason do you have for not wanting to concatenate the return
value as per the commented out piece of code? If it bothers you that much,
try something else:
my %params = $q->Vars();
$cTestvar = "The value $params{'pass'} was passed in...";
Matt
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7595
***************************************