[15492] in Perl-Users-Digest
Perl-Users Digest, Issue: 2902 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 29 06:05:29 2000
Date: Sat, 29 Apr 2000 03:05:09 -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: <957002709-v9-i2902@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 29 Apr 2000 Volume: 9 Number: 2902
Today's topics:
Re: Any electronic perl book to share (pdf will be a bo lvirden@cas.org
Re: Denoument (Was: perl in NT .BAT files Question) <DNess@Home.Com>
Re: Evaluating string as math expression (Neil Kandalgaonkar)
Re: Hashes -- case insensitive keys? (Ilya Zakharevich)
Help I'm at a loss! <dzapped@theramp.net>
Re: help with @inc please jlamport@calarts.edu
Re: Help!! cannot redirect a frame document after submi <care227@attglobal.net>
Re: HOW CAN I TELL... (OT) <dennis_marti@yahoo.com>
how to "uudecode" binaries? <ub@europe.de>
Idea: Soft sub refs and taint? (Neil Kandalgaonkar)
Re: If slices are so great... (Andrew Johnson)
Re: If slices are so great... <uri@sysarch.com>
interesting semantic distinction... jlamport@calarts.edu
Re: interesting semantic distinction... (Neil Kandalgaonkar)
Re: mod-rewrite redirect using regexp <godzilla@stomp.stomp.tokyo>
Re: mod-rewrite redirect using regexp (Coke Harrington)
program that prints itself <johnlin@chttl.com.tw>
regex <chris@aol.com>
Re: regex jlamport@calarts.edu
Re: Something isn't working, and I can't figure it out <care227@attglobal.net>
Re: Something isn't working, and I can't figure it out <care227@attglobal.net>
Re: Something isn't working, and I can't figure it out <uri@sysarch.com>
Re: Something isn't working, and I can't figure it out (Coke Harrington)
Re: Weird locale error opening file <frankvw@euronet.nl>
Weird Problem With Perl DBI and MySQL otrcomm@wildapache.net
Re: which subs are defined (Neil Kandalgaonkar)
Which template module? CGI::FastTemplate? <webmaster@momsathome.on.ca>
Re: why is thi not working? <andrew.mcguire@walgreens.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Apr 2000 09:30:25 GMT
From: lvirden@cas.org
Subject: Re: Any electronic perl book to share (pdf will be a bonus)
Message-Id: <8eea3h$iem$1@srv38.cas.org>
According to Norazman Abu Sahir <norazman@ti.com>:
:Do you have any "electronic version" that I can use. I prefer to read more than
:I source/book
:no matter what's the level. or can you point to any site that have the
:electronic version (downloadable
:will be better). Thanks.
The documentation that comes with the Perl source code (known as the pod
files) is a pretty rich set of information that, if read and understood,
should answer quite a lot of your questions. However, in general it
is _reference_ documentation, not tutorial documentation.
If you are already comfortable programming in other languages, then it
may be sufficient for learning Perl.
Along with this are articles written at a variety of levels designed to
teach you far more than you ever wanted to know <smile> about a variety
of topics, articles written for a variety of electronic magazines, etc.
What I do not have as an easy reference is a pointer to a 'bibliography'
of these online articles. However, I've seen articles (tutorials,
how tos, etc.) at sites like developers.com, perhaps even webmonkey.com, etc.
Hopefully others will follow up with more information on sites with
tutorial articles, etc.
--
<URL: http://dev.scriptics.com/>
<URL: mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
Date: Sat, 29 Apr 2000 05:28:47 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: Denoument (Was: perl in NT .BAT files Question)
Message-Id: <390A7318.6AEAB1C5@Home.Com>
Steve Kemp wrote:
>
> Ah, of course that was my mistake.
>
> What I should hav said is use:
>
> perl %PerlFlag% %~f0 %*
>
Well, I tried it, and there's good news and bad news.
The good news is that this works very well under NT and Win2K.
The bad news is that it doesn't work at all under 98 or 95.
So, since my home network has 2-NTs, 2-98s, a 95 and 2K, I have to stick
with the one that works everywhere.
Anyway, thanks for all the help, even if it finally ran into this
obstacle...
------------------------------
Date: 29 Apr 2000 09:09:51 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Evaluating string as math expression
Message-Id: <8ee8sv$2js$1@newsflash.concordia.ca>
In article <sgk07nkg7qo145@corp.supernews.com>,
Craig Berry <cberry@cinenet.net> wrote:
>Sigurd Schi|th (sigurd.schioth@ilf.uio.no) wrote:
>: Is there a compact (and pref. fast) way to evaluate/convert a string
>: as/to a mathematical expression in Perl (without splitting and
>: iterating)? Say, for a string like "1+2*3" I want the scalar '7'.
>
>If you use standard Perl math syntax, eval() makes this a breeze:
There's a module on the CPAN called Math::Expr for creating mathematical
expression parse trees and (?) returning their results. I can't quite figure
it out in less than 5 min, but it might be useful to you.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: 29 Apr 2000 05:25:01 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <8edrnd$pv8$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tad McClellan
<tadmc@metronet.com>],
who wrote in article <slrn8gj6us.2io.tadmc@magna.metronet.com>:
> But it _does_ return a sorted list.
Nope.
> It is sorted according to the (internal) hash function.
If it were, then the order would not depend on the way keys were
added/deleted to/from the hash. But it does (AFAI can deduce).
Ilya
------------------------------
Date: Sat, 29 Apr 2000 00:26:07 -0500
From: Z-man <dzapped@theramp.net>
Subject: Help I'm at a loss!
Message-Id: <390A726F.FB5C1246@theramp.net>
Please Help I'm running my scripts on a win98 box.I have one script that
I can't seem to get past this error the statement is as follows:
if ($in{'update_html'}) {
&demo_html;
$pid=fork();
if ($pid) {
&header_html;
&script_setup_html;
&footer_html;
} else {
close (STDOUT);
&update_html1;
}
}
Now I know fork is unimplemented on windows ,normally if i remove a
reference to it the scripts run,
in this case if i remove fork the script returns doc contains no data,If
I leave it in when i call that function of the script I get an error
message from perl saying this program has performed an illegal operation
and so on,Yet the script does update the html as it's supposed to.If any
one can help I'd apprecite it...
TIA
Denis
------------------------------
Date: Sat, 29 Apr 2000 06:40:04 GMT
From: jlamport@calarts.edu
Subject: Re: help with @inc please
Message-Id: <8ee044$sgs$1@nnrp1.deja.com>
In article <Pine.GSO.4.10.10004282002410.21722-100000@user2.teleport.com>
,
Tom Phoenix <rootbeer@redcat.com> wrote:
>
> Check what the FAQ says about keeping your own directory for modules,
And if you find out just *where* I can find this elusive FAQ, let me
know. I asked about this recently and only got some snotty suggestion
about grep'ing through the entire perl installation on my system.
> and
> see the docs for the 'lib' pragma.
This cryptic remark is intended, I believe, to point you towards these:
man perlmodlib
perldoc lib
Hope this helps!
-jason
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 29 Apr 2000 00:34:22 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Help!! cannot redirect a frame document after submit
Message-Id: <390A664E.AB53B84C@attglobal.net>
ec wrote:
>
> Hi,
>
> I'm fairly new to Perl, and I'm having a very hard time
> trying to redirect a document in perl/cgi.
You said CGI.
Try this question in comp.infosystems.www.authoring.cgi
Followup set.
------------------------------
Date: Sat, 29 Apr 2000 01:45:08 -0400
From: Dennis Marti <dennis_marti@yahoo.com>
Subject: Re: HOW CAN I TELL... (OT)
Message-Id: <dennis_marti-B8D5EA.01450829042000@news.starpower.net>
In article <MPG.1373a45461592b1198a9ae@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:
> On 'most' operating systems (i.e., on the operating systems that run 90%
> or more of the world's computers), the system imposes a mandatory lock
Where did you find this statistic? I'm still looking, but, so far,
haven't been able to verify it.
Dennis
------------------------------
Date: Sat, 29 Apr 2000 08:07:30 +0200
From: ULf Berger <ub@europe.de>
Subject: how to "uudecode" binaries?
Message-Id: <390A7C22.CEBA0F6B@europe.de>
hi perlers,
this is a question about "uudecode".
i need/want to write an downloader for usenet binaries (pictures) in
perl.
i managed to receive binaries (news::nntpclient), but i failed in
decoding them.
here is the code: (result is a corrupt file)
while (<FILE1>) { # uuencoded source
next unless ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/;
open(FILE2,">$file") or die "Can't create $file: $!\n";
while (<FILE1>) {
last if /^end/;
next if /[a-z]/;
next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() /
4);
print FILE2 unpack("u", $_);
}
close FILE2;
}
close FILE1;
i also tried using "convert::uu" but failed again :-(
any tips or code samples are welcome,
thank you.
Ulf
------------------------------
Date: 29 Apr 2000 08:19:29 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Idea: Soft sub refs and taint?
Message-Id: <8ee5uh$7gs$1@newsflash.concordia.ca>
Perhaps soft subroutine references should fail if the data is
tainted?
&{$tainted}; # fatal under notional new taint feature.
I got the idea answering another poster's question where
he wanted to use HTML form data to call a function.
Not that it would have helped that poster anyway, since he
was probably not using taint, it just seems like an
obvious taintworthy feature. I don't see it in perlsec and
this test seems to show it could be a legitimate security
problem.
#!/usr/bin/perl -Tw
#
# Make a file called foo.txt in the cwd, and some other file,
# say foo2.txt. Type "rmfile" and "foo2.txt" at the prompts.
undef %ENV;
print "Sub: ";
my $sub = <>;
print "Data: ";
my $data = <>;
chomp ($sub, $data);
&{$sub}($data);
sub rmfile {
my ($file) = @_;
unlink("foo.txt") and print "removed foo.txt\n"; # works!
unlink($file) and print "removed $file\n"; # -T stops this
}
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Sat, 29 Apr 2000 05:54:33 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: If slices are so great...
Message-Id: <tOuO4.9357$95.75850@news1.rdc1.mb.home.com>
In article <x7n1md27k9.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
[snip]
> or this cool and ugly splice trick:
>
> @keep = splice( @{[ split( /,/, $string )]}, 2 ) ;
almost makes one wish for a complement notation for
subscripts -- maybe similar to regex negative char classes
by using the caret: (somelist)[^1,4,6] would return all but
elements 1, 4, and 6 of somelist. Then we could just:
@keep = (split /,/, $string)[^0,1];
regards,
andrew
--
Andrew L. Johnson http://members.home.net/andrew-johnson/epwp.html
But puzzles in programming are what make it challenging and fun
sometimes... you always end up learning one more way not to do
something each time. -- Brad Fenwick
------------------------------
Date: Sat, 29 Apr 2000 06:02:02 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: If slices are so great...
Message-Id: <x7u2glzbqe.fsf@home.sysarch.com>
>>>>> "AJ" == Andrew Johnson <andrew-johnson@home.com> writes:
AJ> In article <x7n1md27k9.fsf@home.sysarch.com>,
AJ> Uri Guttman <uri@sysarch.com> wrote:
>> @keep = splice( @{[ split( /,/, $string )]}, 2 ) ;
AJ> almost makes one wish for a complement notation for
AJ> subscripts -- maybe similar to regex negative char classes
AJ> by using the caret: (somelist)[^1,4,6] would return all but
AJ> elements 1, 4, and 6 of somelist. Then we could just:
AJ> @keep = (split /,/, $string)[^0,1];
you are truly warped. must be a requirement to write for manning
(factoring in the mental state of damian)
:)
maybe for 5.8? (5.7 will be maintenance release which is needed)
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 29 Apr 2000 07:26:37 GMT
From: jlamport@calarts.edu
Subject: interesting semantic distinction...
Message-Id: <8ee2r7$vt1$1@nnrp1.deja.com>
While playing around with tied filenhandles, I discovered something new.
The perl gurus here already know this, I'm sure, but it was news to me,
and something I've never seen documented anywhere, and it could be a very
useful bit of information:
while(<FH>) {
...
}
is *not* semantically equivalent to
while($_=<FH>) {
...
}
it is, instead, semantically equivalent (I think) to
while( defined($_=<FH>) ) {
...
}
Which makes sense (since you could want to capture the last line of a
file that ended with "...\n0" and no newline, or you might want to set $/
='0' for some strange reason, and not want your loop to terminate when it
hits '00', or...)
Hope this is useful to someone...
-jason
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Apr 2000 08:29:55 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: interesting semantic distinction...
Message-Id: <8ee6i3$84u$1@newsflash.concordia.ca>
In article <8ee2r7$vt1$1@nnrp1.deja.com>, <jlamport@calarts.edu> wrote:
>while( defined($_=<FH>) ) {
> ...
>}
Yes, it's a nifty feature of perl. However, it *is* documented near the
end of man perlop, grep for 'I/O Operators'.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Fri, 28 Apr 2000 21:30:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: mod-rewrite redirect using regexp
Message-Id: <390A655B.5FB34823@stomp.stomp.tokyo>
Dimitri Ostapenko wrote:
> I'm sorry to post this here, but I already tried
> com.infosystems.www.servers and couldn't get an answer.
> I need to redirect to perl script based on substring in URL:
> http://www.xyz.com/q.phtml?client=AAA
> to
> http://www.xyz.com/redir.pl?file=q.phtml&client=AAA
Dimitri, with this software you are using, regardless
of your rule sets, for this to work, your final output
must be in this general format:
http...etc/redir.pl?Key=Value&Key=Value
Your client=AAA would pass just fine. I am not
so sure your q.phtml would because of the period
in there. This depends a lot on your read/parse
routine and how it would handle this. Probably
ok on this but double check.
> RewriteEngine On
> RewriteBase /
> RewriteRule ^([^?&]+)[?&]client=([^/?&]+)redir.pl?file=$1&client=$2 [NC]
> Now '&' works just fine, but '?' does not, even prepended
> with '\' (which it shouldn't be in char class anyway). I
> also can't match ? before client with '.', \?, \S
Escaping a question mark ? does not alway work
as you think it will. There are circumstances
when standard techniques completely fail, much
to your surprise and disbelieve of others. Looks
like you are learning this as I did long ago.
There is a way to avoid a lot of meta-characters
by using "less fancy" matching operators. I will
close with an example of less eloquence but greater
ease in writing.
Here is what I would suggest on this Dimitri. You are
working with some software with which not many people
are experienced. If it was me wearing your programmer
hat, I would go to this page:
http://www.apache.org/docs/mod/mod_rewrite.html
Study well what is there to get a "feel" for how
this works. I would _literally_ study every item
listed to get to know this software inside and out.
I would also try hard to mimic his examples as
closely as possible for testing and learning,
I mean actually use his URL addresses and all,
as if I am really going to setup just as he
outlines on that page. Then try it.
This is not easy software to master without a good
basic knowledge of how it works. Once you know
this software like a long time lover, you will
feel less awkward. To truly please a lover, you
must engage in a lots of foreplay, it this case,
learning all you can, before doing it. ;)
For now, consider this sincere suggestion.
Backup on your rules for redirect. Start with
the most simple possible redirect rule you
can write, get it working, then add a little
bit more to it slowly. Test a lot, add a little.
Avoid meta-characters at first, they will eat
your mind in a hurry.
KISS : Keep It Simple Silly
You are dealing with standard Perl style
matching operators. There are lots and
lots of sites and reference material
available to assist you in writing
correct rules for your software.
Make use of those resources.
Get to know this software by studying
his page, testing his examples. Read
up on regex formats. You will do ok
in time, if you put out effort.
Here is something which might point you
in a right direction for your rules, a
simple one to catch most addresses but
is not a copy and paste, it is a character
set format which may help you by analogy:
!(http://[~\-a-z0-9_/\.]+\.\S+)! your redirect here !
This is the best I can offer to point you
to thinking about how you might want to
approach this, AFTER you study his site
pages forwards, backwards and upside down.
Godzilla!
------------------------------
Date: Sat, 29 Apr 2000 04:53:41 GMT
From: coke@cokesque.com (Coke Harrington)
Subject: Re: mod-rewrite redirect using regexp
Message-Id: <slrn8gkr5j.1ng.coke@scallop.lan.cokesque.com>
On Fri, 28 Apr 2000 21:30:19 -0700, Godzilla! wrote:
[lots of standard PG blather]
That'll teach him to ask Apache questions in clp.misc :-)
--
Coke Harrington
------------------------------
Date: Sat, 29 Apr 2000 15:57:46 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: program that prints itself
Message-Id: <8ee4nn$hkn@netnews.hinet.net>
Dear all,
There was an old question in the age of APPLE II:
Write a BASIC program that prints itself.
Then, when C got popular, it became:
Write a C program that prints itself.
I wonder what the program would be like in Perl.
Will you try to solve it?
Thank you.
John Lin
------------------------------
Date: Sat, 29 Apr 2000 00:00:49 -0700
From: chris <chris@aol.com>
Subject: regex
Message-Id: <390A88A0.D9D7A0C7@aol.com>
will this work
$one =~ s/book/do 'script.pl'/e;
and will this work
$one =~ s/book/script.pl/e;
please help
------------------------------
Date: Sat, 29 Apr 2000 06:56:57 GMT
From: jlamport@calarts.edu
Subject: Re: regex
Message-Id: <8ee13m$t59$1@nnrp1.deja.com>
In article <390A88A0.D9D7A0C7@aol.com>,
chris <chris@aol.com> wrote:
> will this work
> $one =~ s/book/do 'script.pl'/e;
If $one contains the string 'book', then this will load the script
'script.pl', execute it, and replace the first occurance in $one of the
string 'book' with the last expression to be evaluated in 'script.pl'.
If this is what you want, then yes, this works.
>
> and will this work
>
> $one =~ s/book/script.pl/e;
If $one contains the string 'book', then this will call the subroutine
named script, then call the subroutine named pl, and replace the first
occurance in $one of the string 'book' with the concatenated return
values of the two subroutines. If this is what you want, then yes, this
works.
(hint: this version could be more clearly written as:
$one =~ s/book/ script() . pl() /e;
)
HTH,
-jason
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 29 Apr 2000 00:11:48 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <390A6104.B10D4DF6@attglobal.net>
Tom Phoenix wrote:
>
> If that line of code passes the value of the variable $acct rather than
> the five-character string '$acct' to start_form, then there's something
> seriously (and very surprisingly!) wrong with your perl.
Yes, single quotes aren't supposed to behave that way. But...
i put the script live for your perusal.
http://rrtools.ibm.net/cgi-bin/addpage.cgi
Just put whatever in the Account field and hit next, then view source.
on the next page. The source for the script is at
http://rrtools.ibm.net/addpage.txt
> Please, check again. Could your real code perhaps use no quotes or double
> quotes around the item after '-value'? Could it be that you're seeing the
> value of $acct elsewhere in your output?
Here's whats odd:
The string is quoted with single quotes (not at all sure why I did
that, but im also not sure why it took me a week to notice that the
form was submiting 'yes' or 'no', but the script was expecting 'on' or
'off') and when I get the value of $acct like this:
$acct = param('account_id'); and then use it later, it works.
Otherwise it doesn't.
> If you're certain that this is really working as you say, please cut your
> code down to the smallest possible self-contained example which shows this
> behavior, then please post that. Thanks.
>
#!/usr/bin/perl -w
use 5.004;
use CGI qw(:standard);
my $acct = 'JohnJacobJingleHiemerSchmidt'; #case 1
# my $acct = param('acct_id'); #case 2
print header,
start_html,
h3({-align=>CENTER}, 'Test of odd quote behaviour'),
start_form(-action=>'/cgi-bin/addpage.cgi', -method=>POST),
hidden(-name=>'acct_id', -value=>'$acct'),
p("Check the source for odd behaviour"),
end_form,
end_html;
Case 1 prints as we'd expect it, no variable interpretation. Case 2
as we would not expect it, $acct is printed as whatever is passed to the
script.
------------------------------
Date: Sat, 29 Apr 2000 00:13:36 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <390A6170.DBD7A267@attglobal.net>
In any event, that value is only used in a hidden field, and is not
tested for in any way anywhere. Would the misquoting cause the
script to misbehave in the way that I described (or attempted to)
in the origional post?
------------------------------
Date: Sat, 29 Apr 2000 05:09:47 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <x7ya5xze5j.fsf@home.sysarch.com>
>>>>> "DS" == Drew Simonis <care227@attglobal.net> writes:
DS> my $acct = 'JohnJacobJingleHiemerSchmidt'; #case 1
DS> # my $acct = param('acct_id'); #case 2
DS> print header,
DS> start_html,
DS> h3({-align=>CENTER}, 'Test of odd quote behaviour'),
DS> start_form(-action=>'/cgi-bin/addpage.cgi', -method=>POST),
DS> hidden(-name=>'acct_id', -value=>'$acct'),
^ ^
why the quotes there? that is totally wrong. just remove them.
DS> Case 1 prints as we'd expect it, no variable interpretation. Case
DS> 2 as we would not expect it, $acct is printed as whatever is
DS> passed to the script.
are you sure? i ran this offline and this is the output:
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Untitled Document</TITLE> </HEAD><BODY><H3
ALIGN="CENTER">Test of odd quote behaviour</H3><FORM METHOD="POST"
ACTION="/cgi-bin/addpage.cgi"
ENCTYPE="application/x-www-form-urlencoded"> <INPUT TYPE="hidden"
NAME="acct_id" VALUE="$acct"><P>Check the source for odd
^^^^^
behaviour</P></FORM></BODY></HTML>
i rewrapped it for readability. you should print newlines in your html
to make it easier to debug. also i bet you are not looking at this
output offline. one of the best (and least mentioned sometimes) features
of cgi.pm is very easy offline testing.
note the value of the hidden var is $acct which is not what you
wanted. that is the literal string because you used single quotes above.
when i fixed the quotes and reran it like this:
perl foo.cgi acct_id=junk
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Untitled Document</TITLE> </HEAD><BODY><H3
ALIGN="CENTER">Test of odd quote behaviour</H3><FORM METHOD="POST"
ACTION="/cgi-bin/addpage.cgi"
ENCTYPE="application/x-www-form-urlencoded"> <INPUT TYPE="hidden"
NAME="acct_id" VALUE="junk"><P>Check the source for odd
^^^^
behaviour</P></FORM></BODY></HTML>
it prints the proper value of the hidden param.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 29 Apr 2000 05:19:47 GMT
From: coke@cokesque.com (Coke Harrington)
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <slrn8gkskf.1ng.coke@scallop.lan.cokesque.com>
On Sat, 29 Apr 2000 00:11:48 -0400, Drew Simonis wrote:
> hidden(-name=>'acct_id', -value=>'$acct'),
^^^^^^^^^^^^^^^
As part of its "sticky" forms feature, CGI.pm will use the above value
for acct_id only if param('acct_id') is undefined or if you explicitly
set the -override parameter to true.
Perl appears to interpolate the single-quoted string because $acct and
param('acct_id') happen to be equivalent values.
--
Coke Harrington
------------------------------
Date: Sat, 29 Apr 2000 11:15:33 +0200
From: Frank van Wensveen <frankvw@euronet.nl>
Subject: Re: Weird locale error opening file
Message-Id: <au9lgs863rc3pvg2ehcfeklgmbm73qolnu@4ax.com>
On 27 Apr 2000 22:16:57 +0100, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:
> > So the question remains: WHY is the opening of locale files related to
> > the tied file being shared?
> It hasnt anything to do with it.
Yes it has. If the tied file isn't shared, no attempt is made to open
locale files. If it is, the program starts searching for local files.
Since this is reproducable, I see a connection.
> If you dont understand what you are seeing from strace just ignore.
I understand what I'm seeing. I just don't understand why it's there.
(But let's not get existential here...)
Regards,
Frank
============================================
Email: frankvw@euronet.nl
Homepage: http://www.euronet.nl/~frankvw
ICQ #: 13800170
============================================
------------------------------
Date: Sat, 29 Apr 2000 08:34:53 GMT
From: otrcomm@wildapache.net
Subject: Weird Problem With Perl DBI and MySQL
Message-Id: <390a99d3.707801064@news.wildapache.net>
Hello,
I have a weird problem here.
I have a database/table in MySQL and am trying use a perl script to update
one of the fields.
The code is written as so:
...
...
...
$SQL = qq{UPDATE transactions
SET status="markret"
WHERE code = "000129-1"};
DBI->trace(2,"dbi.out");
$sth = $dbh->prepare ($SQL) or die "Cannot SELECT from $table" ;
# excute the query
$sth->execute or die "Cannot execute SELECT from $table";
$sth->finish if $sth;
DBI->trace(0);
...
...
...
Here is the output from the trace:
DBI 1.13-nothread dispatch trace level set to 2
-> prepare for DBD::mysql::db (DBI::db=HASH(0x839e474)~0x8395c40
'UPDATE transactions
SET status="markret"
WHERE code = "000129-3"')
Setting mysql_use_result to 0
<- prepare= DBI::st=HASH(0x8398094) at minicyber.subs line 589.
-> DESTROY for DBD::mysql::st (DBI::st=HASH(0x8398010)~INNER)
<- DESTROY= undef at minicyber.subs line 592.
-> execute for DBD::mysql::st (DBI::st=HASH(0x8398094)~0x838c328)
-> dbd_st_execute for 08395d90
<- dbd_st_execute 0 rows
<- execute= '0E0' at minicyber.subs line 592.
-> finish for DBD::mysql::st (DBI::st=HASH(0x8398094)~0x838c328)
<- finish= 1 at minicyber.subs line 596.
Now the problem is that the 'status' field in my database does not get
updated to 'markret'.
I do not have experience in reading the traces from DBI, so I do not know
how to decipher this output.
Does anyone have any ideas about what is going on here?
Thank you,
Murrah Boswell
otrcomm@wildapache.net
------------------------------
Date: 29 Apr 2000 07:47:45 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: which subs are defined
Message-Id: <8ee431$pqv$1@newsflash.concordia.ca>
In article <27080b08.06e132c8@usw-ex0102-016.remarq.com>,
Richard A. DeVenezia <ctemp5NOctSPAM@specialmetals.com.invalid> wrote:
>I have a form which allows a user to enter a 'method' to run.
>The method is a sub in a perl program.
>
>e.g. input field method has value xyz entered into it and a form
>is submitted.
>
>$method = $q->param('method');
># Is there a way I can check if xyz is a sub before calling the
>sub $method ?
>&$method();
You can use defined() to test for definedness of subroutines.
See perldoc -tf defined.
However, it is an incredibly bad idea to execute a function just
because some user on the internet sent it to you via a form, and
it happens to be defined. (Hint: form values are trivially hackable).
You're better off with explicit testing of the acceptable options.
my %allowed_func = map { $_ => 1 } qw(display order confirm thanks);
if ( $allowed_func{ $q->param('method') } ) {
&{$q->param('method')}
}
Even that uses icky soft references which should give you the
heebie-jeebies. But this should be secure enough.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Sat, 29 Apr 2000 01:10:28 -0400
From: Jennifer <webmaster@momsathome.on.ca>
Subject: Which template module? CGI::FastTemplate?
Message-Id: <390A6EC4.77970071@momsathome.on.ca>
There seems to be an abundance of template modules out there.
I've read about Text::Template, Text::FillIn, Text::MetaText,
HTML::Template, HTML::ParsedForm, and CGI::FastTemplate
It looks like CGI::FastTemplate is the best one for my needs. I
like many of the features in the other ones, but my client does
her own HTML (although I wish she wouldn't). I usually have to
clean up her HTML afterwards too, so the simpler the better. I
don't want any logic in the HTML.
Are there any other modules on templates that I missed?
Is CGI::FastTemplate still supported? Right now I am hand-coding
it and I don't want to move everything over to a module if I may
have to move it all again later. But I am in the process of a
rewrite at the moment, so if I going to change anything now is
the time to do it.
Also, I don't see an option to choose my variable format with
this module. I have tons of templates already using
<%VARIABLE%>. Any chance that this module will add this in the
future? Should I change all my variables? Or should I hack the
module? What would be involved in hacking the module for this?
Just changing the regexp in the parse sub? or is there more to
it than that?
Jennifer
------------------------------
Date: Sat, 29 Apr 2000 00:20:31 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: why is thi not working?
Message-Id: <390A711F.3E409F12@walgreens.com>
Brian Smith wrote:
>
> The thing is, the second message I posted was not ment to be a quetion. But
> a statment.
[ snip of jeopardized content ]
Well in that case, since you still dont want to follow
the rules, and post jeopardy style... No, never mind.
I will give you one more chance, no plonking yet...
Please follow the advice in my previous post, Lauren
seconded my advice as well. You really should learn
the rules of engagement before engaging your target.
Now, PLEASE, go read news.announce.newusers, and RFC 1855.
They will help you tremendously, as you will get better
and more thoughtful answers to your posts. Many experts
here I am sure have already killfiled you for your lack
of adherance to the rules. I am not an expert, but I have
seen people here get killfiled after one jeopardy post.
Do yourself, and Usenet a favor, and RTM, as I am sure
you have much to contribute, and you would probably like
what you have to say to be heard.
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 2902
**************************************