[31596] in Perl-Users-Digest
Perl-Users Digest, Issue: 2855 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 6 14:09:25 2010
Date: Sat, 6 Mar 2010 11:09:08 -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 Sat, 6 Mar 2010 Volume: 11 Number: 2855
Today's topics:
Apache2::Request doesn't work as expected <kwan.jingx@gmail.com>
Re: Apache2::Request doesn't work as expected <smallpond@juno.com>
Re: Apache2::Request doesn't work as expected <john@castleamber.com>
Re: Core dump with "in memory" file <hjp-usenet2@hjp.at>
Re: Detecting Bourne (or csh) shell from Perl <nospam-abuse@ilyaz.org>
Re: floating point issue? <hjp-usenet2@hjp.at>
Re: floating point issue? <sreservoir@gmail.com>
Re: floating point issue? <jurgenex@hotmail.com>
Re: floating point issue? <rvtol+usenet@xs4all.nl>
Re: floating point issue? <jurgenex@hotmail.com>
Re: floating point issue? <sreservoir@gmail.com>
Re: floating point issue? <kst-u@mib.org>
Re: Is there a "poor man's" perldoc? <mvdwege@mail.com>
Re: Is there a "poor man's" perldoc? <hjp-usenet2@hjp.at>
Re: Is there a "poor man's" perldoc? <xhoster@gmail.com>
Re: Prevent script from adding an extra line at the end <justin.1003@purestblue.com>
Re: Prevent script from adding an extra line at the end <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 5 Mar 2010 15:31:37 -0800 (PST)
From: kwan <kwan.jingx@gmail.com>
Subject: Apache2::Request doesn't work as expected
Message-Id: <f91bc395-7408-4ef2-a939-82b5ef876dc2@t20g2000yqe.googlegroups.com>
Hello,
I wrote a mod_perl to check some of the value that users select. The
script will generate a form according to the selection from the user.
There are three forms that are dynamically generated according to the
selection,
in the "display form", there are links to the "add form" and
"modify form".
in the "add form", there are links to the "display form" and
modify form".
in the "modify form", there are links to the display form"
and "add from".
In each link, it is like this:
http://hostname:80/mainform?selection=display
http://hostname:80/mainform?selection=modify
http://hostname:80/mainform?selection=add
within the form, I also have the submit form for user to submit the
content to the server.
the submit form is: <input type="submit" name="selection"
value='Add Content'>
Before, when I use "use CGI" package I can use "param", and the form
will be generate and query according to the user submit.
Code:
my $selection = lc (param('selection'));
if ($selection eq "add content") { }# work with CGI, but
not with Apache2::Request::param
elsif ($selection eq "modify") {} # work both
elsif ($selection eq "add") {} # work both
elsif ($selection eq "display"){} # work both
elsif ($selection eq "modify content"){} # work with CGI,
but not with Apache2::Request:param
when using CGI, I can get the "param" work according to the user
selection. However, when I replace to the following code by using
Apache2::Request, when user select modify form, and submit the form.
the $r->param('selection') is failed to identify the "modify content"
value.
my $rq = new Apache2::Request($r);
my $selection = lc ($rq->param('selection'));
I've followed the perldoc Apache2::Request, it isn't much infor about
the
behavior of the Apache2::Request, as it is mimic the CGI.
Thank
------------------------------
Date: Sat, 6 Mar 2010 09:59:11 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Apache2::Request doesn't work as expected
Message-Id: <7693aca8-198a-4550-8296-568a0101e743@q23g2000yqd.googlegroups.com>
On Mar 5, 6:31=A0pm, kwan <kwan.ji...@gmail.com> wrote:
> Hello,
>
> I wrote a mod_perl to check some of the value that users select. The
> script will generate a form according to the selection from the user.
> There are three forms that are dynamically generated according to the
> selection,
> =A0 =A0 =A0 =A0 =A0in the "display form", there are links to the "add for=
m" and
> "modify form".
> =A0 =A0 =A0 =A0 =A0in the "add form", there are links to the "display for=
m" and
> modify form".
> =A0 =A0 =A0 =A0 =A0in the "modify form", there are links to the display f=
orm"
> and "add from".
>
> In each link, it is like this:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://hostname:80/mainform?select=
ion=3Ddisplay
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://hostname:80/mainform?select=
ion=3Dmodify
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://hostname:80/mainform?select=
ion=3Dadd
>
> within the form, I also have the submit form for user to submit the
> content to the server.
> the submit form is: <input type=3D"submit" name=3D"selection"
> value=3D'Add Content'>
>
> Before, when I use "use CGI" package I can use "param", and the form
> will be generate and query according to the user submit.
> Code:
> =A0 =A0 =A0 =A0 =A0 my $selection =3D lc (param('selection'));
> =A0 =A0 =A0 =A0 =A0 if ($selection eq "add content") { =A0 =A0}# work wit=
h CGI, but
> not with Apache2::Request::param
> =A0 =A0 =A0 =A0 =A0 elsif ($selection eq "modify") {} =A0# work both
> =A0 =A0 =A0 =A0 =A0 elsif ($selection eq "add") {} =A0 =A0 =A0 # work bot=
h
> =A0 =A0 =A0 =A0 =A0 elsif ($selection eq "display"){} =A0 # work both
> =A0 =A0 =A0 =A0 =A0 elsif ($selection eq "modify content"){} # work with =
CGI,
> but not with Apache2::Request:param
>
> when using CGI, I can get the "param" work according to the user
> selection. However, when I replace =A0to the following code by using
> Apache2::Request, when user select modify form, and submit the form.
> the $r->param('selection') is failed to identify the "modify content"
> value.
>
> my $rq =3D new Apache2::Request($r);
> my $selection =3D lc ($rq->param('selection'));
>
> I've followed the perldoc Apache2::Request, it isn't much infor about
> the
> behavior of the Apache2::Request, as it is mimic the CGI.
>
Single quotes are not used in html. It should be:
<input type=3D"submit" name=3D"selection" value=3D"Add Content">
Spaces are excluded by HTTP. It should be encoded as
"Add%20Content" in the URL. You can print the params to see
what you are getting.
------------------------------
Date: Sat, 06 Mar 2010 12:10:47 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: Apache2::Request doesn't work as expected
Message-Id: <87d3zhl3rs.fsf@castleamber.com>
smallpond <smallpond@juno.com> writes:
> Single quotes are not used in html. It should be:
> <input type="submit" name="selection" value="Add Content">
Not true
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Sat, 6 Mar 2010 10:23:59 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Core dump with "in memory" file
Message-Id: <slrnhp47pf.cq5.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-05 01:47, Ben Morrow <ben@morrow.me.uk> wrote:
> It's a bug in perl, but it appears to have been fixed in blead. The fix
> will be in 5.10.0, and probably in 5.10.2 if there ever is one
5.12.0?
hp
------------------------------
Date: Sat, 6 Mar 2010 04:57:27 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Detecting Bourne (or csh) shell from Perl
Message-Id: <slrnhp3o5n.nt5.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-03-04, Ben Morrow <ben@morrow.me.uk> wrote:
> AS and Strawberry (all the various flavours) apply no more than minor
> patches to the core. (This wasn't true once, as I'm sure you remember,
> but ActiveState haven't had their own port for a long time.) Cygwin (and
> Interix and UWin) don't set $^O = "Win32"; as far as Perl is concerned,
> they're mostly a different OS from Win32.
I strongly oppose this misuse of the word "OS"; an OS is an OS - a
port is a port.
Otherwise - a lot of thanks for bringing my attention to Interix and
UWin (this is VERY CLOSE to the kind of info I was asking for). In
other message of this thread, you advocate looking in perlport; but I
find very scarce info about these ports there...
The end result is that I do not know what shell they do use... I'm
afraid one would need to run something like
system qq(echo "1" | $^X -wne "exit 1 unless /\\x22/")
and print "no quote passed through"
each time C::Scan is loaded...
>> I would guess that your understanding of non-Unix architechture is
>> kinda blurred. There are probably tens of different C libraries, none
>> of them "standard"...
> I'm aware of that. However, TTBOMK there aren't any C libraries for
> Win32 which don't use command.com/cmd.exe for system(3).
Are you sure about cygwin one?
> You would at least need to ship with a reasonable set of utilities, as
> well
Not according to my experience. Having a descriptive error message
(such as mv.exe not found, etc) makes more than half of the way.
[Moreover, it is trivial to modify pdksh to load Perl substitutes
for mv etc (in the case no native solution is found), which would
cover most of situationa with a very resource-cheap solution. But
I never needed anything like this for OS/2 port - it is so easy to
get ports of main utilities...]
Thanks,
Ilya
------------------------------
Date: Fri, 5 Mar 2010 23:54:24 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: floating point issue?
Message-Id: <slrnhp32t0.2em.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-03 03:25, Tad McClellan <tadmc@seesig.invalid> wrote:
> kevin0051 <kevin0051@gmail.com> wrote:
>> I made a perl program as follows.
>
> You would have the same problem with any programming language.
Except COBOL or PL/SQL or bc or ...
> The problem is related to how numbers are implemented on computers
> rather than how any particular language behaves.
Not "number implemented on computers" in general, but specific
implementations of numbers. Binary floating point numbers are very
common (because almost all modern processors support them in hardware)
but there are many other possible number implementations.
Decimal fixed or floating point numbers avoid the problem for decimal
fractions, which is sufficient for applications which need to represent
decimal fractions exactly (e.g. financial applications), but they still
have the problem for other fractions (1/3, 1/7, ...).
Rational numbers can be stored as a pair of (potentially big) integers.
There is no way to represent all numbers in a finite amount of memory of
course.
The number representation is not completely independent of the language.
C for example mandates that float, double, etc. are floating point
numbers. They can be binary, decimal or use some other base, but they
can't be fractions, for example.
COBOL provides decimal fixed point data types.
PL/SQL has a decimal floating point type (with 38 digits).
bc has arbitrary precision fixed point numbers.
Perl provides several number representations as modules.
hp
------------------------------
Date: Fri, 05 Mar 2010 19:55:03 -0500
From: sreservoir <sreservoir@gmail.com>
Subject: Re: floating point issue?
Message-Id: <hms95h$1p3$1@speranza.aioe.org>
On 3/5/2010 5:54 PM, Peter J. Holzer wrote:
> On 2010-03-03 03:25, Tad McClellan<tadmc@seesig.invalid> wrote:
>> kevin0051<kevin0051@gmail.com> wrote:
>>> I made a perl program as follows.
>>
>> You would have the same problem with any programming language.
>
> Except COBOL or PL/SQL or bc or ...
bc is made for math and few people actually use the other two anymore.
of course, some lisps use fractions.
> [snipped]
> There is no way to represent all numbers in a finite amount of memory of
> course.
there is no way to represent all numbers full stop.
--
"Six by nine. Forty two."
"That's it. That's all there is."
"I always thought something was fundamentally wrong with the universe"
------------------------------
Date: Fri, 05 Mar 2010 17:15:04 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: floating point issue?
Message-Id: <hta3p51ptot2olqvcr77qlfe4nhumj3hvu@4ax.com>
sreservoir <sreservoir@gmail.com> wrote:
>On 3/5/2010 5:54 PM, Peter J. Holzer wrote:
>> There is no way to represent all numbers in a finite amount of memory of
>> course.
>
>there is no way to represent all numbers full stop.
This is becoming philosophical now, but you can represent any number. In
the worst case you simply use a verbal description. Granted, that
doesn't do you much good if you want to use that number in a calculation
on the computer, but it is possible to represent it because otherwise
you wouldn't be able to think of this number in the first place.
jue
------------------------------
Date: Sat, 06 Mar 2010 02:40:01 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: floating point issue?
Message-Id: <4b91b272$0$22935$e4fe514c@news.xs4all.nl>
Jürgen Exner wrote:
> sreservoir <sreservoir@gmail.com> wrote:
>> On 3/5/2010 5:54 PM, Peter J. Holzer wrote:
>>> There is no way to represent all numbers in a finite amount of memory of
>>> course.
>>
>> there is no way to represent all numbers full stop.
>
> This is becoming philosophical now, but you can represent any number. In
> the worst case you simply use a verbal description. Granted, that
> doesn't do you much good if you want to use that number in a calculation
> on the computer, but it is possible to represent it because otherwise
> you wouldn't be able to think of this number in the first place.
I think you mean that number almost half way between 2 and 3.
;-)
--
Ruud
------------------------------
Date: Fri, 05 Mar 2010 17:44:11 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: floating point issue?
Message-Id: <8nc3p55chj1arfqltk3goci6ek1n1lnpfs@4ax.com>
"Dr.Ruud" <rvtol+usenet@xs4all.nl> wrote:
>Jürgen Exner wrote:
>> sreservoir <sreservoir@gmail.com> wrote:
>>> On 3/5/2010 5:54 PM, Peter J. Holzer wrote:
>
>>>> There is no way to represent all numbers in a finite amount of memory of
>>>> course.
>>>
>>> there is no way to represent all numbers full stop.
>>
>> This is becoming philosophical now, but you can represent any number. In
>> the worst case you simply use a verbal description. Granted, that
>> doesn't do you much good if you want to use that number in a calculation
>> on the computer, but it is possible to represent it because otherwise
>> you wouldn't be able to think of this number in the first place.
>
>I think you mean that number almost half way between 2 and 3.
>;-)
No, the other one, the one that is exactly a quarter of an epsilon
smaller.
jue
------------------------------
Date: Fri, 05 Mar 2010 21:18:21 -0500
From: sreservoir <sreservoir@gmail.com>
Subject: Re: floating point issue?
Message-Id: <hmse1o$87j$1@speranza.aioe.org>
On 3/5/2010 8:44 PM, Jürgen Exner wrote:
> "Dr.Ruud"<rvtol+usenet@xs4all.nl> wrote:
>> Jürgen Exner wrote:
>>> sreservoir<sreservoir@gmail.com> wrote:
>>>> On 3/5/2010 5:54 PM, Peter J. Holzer wrote:
>>
>>>>> There is no way to represent all numbers in a finite amount of memory of
>>>>> course.
>>>>
>>>> there is no way to represent all numbers full stop.
>>>
>>> This is becoming philosophical now, but you can represent any number. In
>>> the worst case you simply use a verbal description. Granted, that
>>> doesn't do you much good if you want to use that number in a calculation
>>> on the computer, but it is possible to represent it because otherwise
>>> you wouldn't be able to think of this number in the first place.
>>
>> I think you mean that number almost half way between 2 and 3.
>> ;-)
>
> No, the other one, the one that is exactly a quarter of an epsilon
> smaller.
nah, it's actually a two ninths of an epsilon.
--
"Six by nine. Forty two."
"That's it. That's all there is."
"I always thought something was fundamentally wrong with the universe"
------------------------------
Date: Fri, 05 Mar 2010 18:39:27 -0800
From: Keith Thompson <kst-u@mib.org>
Subject: Re: floating point issue?
Message-Id: <lnk4tqqilc.fsf@nuthaus.mib.org>
Jürgen Exner <jurgenex@hotmail.com> writes:
> sreservoir <sreservoir@gmail.com> wrote:
>>On 3/5/2010 5:54 PM, Peter J. Holzer wrote:
>>> There is no way to represent all numbers in a finite amount of memory of
>>> course.
>>
>>there is no way to represent all numbers full stop.
>
> This is becoming philosophical now, but you can represent any number. In
> the worst case you simply use a verbal description. Granted, that
> doesn't do you much good if you want to use that number in a calculation
> on the computer, but it is possible to represent it because otherwise
> you wouldn't be able to think of this number in the first place.
As long as we're being philosophical, being able to think of a number
is not a prerequisite for that number's existence.
The set of finite verbal descriptions is only countably infinite.
There are uncountably infinitely many real numbers.
There are also some lovely paradoxes, such as
"the smallest number that cannot be described in 61 characters".
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
------------------------------
Date: Sat, 06 Mar 2010 10:12:18 +0100
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: Is there a "poor man's" perldoc?
Message-Id: <866359ak5p.fsf@gareth.avalon.lan>
Sherm Pendley <sherm@debian.shermpendley.com> writes:
> "jl_post@hotmail.com" <jl_post@hotmail.com> writes:
>
>> That might work, if only I lived anywhere near the administrator.
>> But in some cases, (s)he's in another country altogether.
>
> There's this thing called "email," you see... :-)
>
>> Sadly, some people just don't think the perldocs are all that
>> important.
>
> Having perldocs on a production server is *not* important.
Quite frankly, I disagree. When I am debugging a production problem, and
part of the problem is perl scripts and/or modules, it's convenient to
read the docs in-place, especially since I know the version of the docs
should fit the deployed perl.
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
------------------------------
Date: Sat, 6 Mar 2010 10:14:52 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Is there a "poor man's" perldoc?
Message-Id: <slrnhp478c.2em.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-05 16:59, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Sherm Pendley <sherm@debian.shermpendley.com> wrote:
>>Ben Morrow <ben@morrow.me.uk> writes:
>>> perldoc almost certainly *is* installed somewhere
>>
>>That's not necessarily true. Many Linux systems package perldoc
>>and the various .pod files into a separate perl-dev or similar
>>package.
>
> Which actually makes sense because you need those only while
> _dev_-eloping Perl code but not on any server that is running perl as a
> utility.
Unless you're a consultant called in to fix something. Then it's damned
convenient to be able to read the docs of the scripts and modules which
are actually installed on the server with the problem instead of those
on your home system without the problem. Oh, and
perldoc -l Module::Name
is also nicer to type than
perl -MModule::Name -le 'print $INC{"Module/Name.pm"}'
hp
------------------------------
Date: Sat, 06 Mar 2010 10:39:25 -0800
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Is there a "poor man's" perldoc?
Message-Id: <4b929f6c$0$1875$ed362ca5@nr5-q3a.newsreader.com>
Mart van de Wege wrote:
> Sherm Pendley <sherm@debian.shermpendley.com> writes:
>
>> "jl_post@hotmail.com" <jl_post@hotmail.com> writes:
>>
>>> Sadly, some people just don't think the perldocs are all that
>>> important.
>> Having perldocs on a production server is *not* important.
>
> Quite frankly, I disagree. When I am debugging a production problem, and
> part of the problem is perl scripts and/or modules, it's convenient to
> read the docs in-place, especially since I know the version of the docs
> should fit the deployed perl.
I run into this problem frequently. I'm trying to debug something on
production server, and discover that not only does it not have perldoc
or man, it also doesn't have top, ps, strace, ltrace, etc. The
resulting conversation goes something like this:
me: "Please install these on the production servers"
IT: "We don't put debugging tools on the production servers because you
are supposed to debug on dev, not production"
me: "The problem does not manifest on dev servers, only production, so
it has to be debugged on production."
IT: "That's impossible, the production servers are identical to the dev
servers."
me: "Obviously not. If they were indentical, then all the debug tools I
just requested would already be there. They aren't."
IT and me: Mutual head explosion.
Xho
------------------------------
Date: Fri, 5 Mar 2010 20:37:49 +0000
From: Justin C <justin.1003@purestblue.com>
Subject: Re: Prevent script from adding an extra line at the end of file
Message-Id: <tl6867-009.ln1@purestblue.com>
In article <slrnhp0762.k17.tadmc@tadbox.sbcglobal.net>, Tad McClellan wrote:
> Don Pich <dpich@polartel.com> wrote:
>
>> Desired output:
>>
>> convert the IP into a quad hex form.
>
>
> print "convert the IP into a quad hex form.\n";
>
>
> Done!
Man you can be obtuse sometimes! :)
Justin.
--
Justin C, by the sea.
------------------------------
Date: Fri, 05 Mar 2010 16:27:28 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Prevent script from adding an extra line at the end of file
Message-Id: <slrnhp313a.oq2.tadmc@tadbox.sbcglobal.net>
Justin C <justin.1003@purestblue.com> wrote:
> In article <slrnhp0762.k17.tadmc@tadbox.sbcglobal.net>, Tad McClellan wrote:
>> Don Pich <dpich@polartel.com> wrote:
>>
>>> Desired output:
>>>
>>> convert the IP into a quad hex form.
>>
>>
>> print "convert the IP into a quad hex form.\n";
>>
>>
>> Done!
>
> Man you can be obtuse sometimes! :)
But in this case, I was being the opposite of obtuse!
We were given a specification to implement, I was clever enough to
see a ridiculously simple way to meet the specification.
A dullard would have done a bunch of bit twiddling/converting, and
when finished, would not have met the (actual) specification!
(though I admit they would have met the implied specification.
My point is that an implied specification is, well, unspecified.
)
Had Don said that in prose, eg:
the desired output is to convert the IP into a quad hex form.
then its meaning would have been clear,
but he labeled it "Desired output:" which to most folks means an
example of the desired output follows, such as:
Desired output:
0a1497fa
0a1497f8
0a1491fc
That is, rather than tell Don his spec was too loose, I instead
showed him that it was. :-)
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 2855
***************************************