[24193] in Perl-Users-Digest
Perl-Users Digest, Issue: 6385 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 11 09:05:55 2004
Date: Sun, 11 Apr 2004 06:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 11 Apr 2004 Volume: 10 Number: 6385
Today's topics:
Re: file access trouble <EatMeSpammers_cwtart@commpay.tv>
Re: How can this be done? <xxala_qumsiehxx@xxyahooxx.com>
Re: How can this be done? <uri@stemsystems.com>
Is there a way to call Perl/Tk from Apache server <oracle@r0b3rt.com>
Re: Is there a way to call Perl/Tk from Apache server <postmaster@castleamber.com>
Re: Is there a way to call Perl/Tk from Apache server <oracle@r0b3rt.com>
Re: Is there a way to call Perl/Tk from Apache server <jwillmore@remove.adelphia.net>
Re: new bbs <me@privacy.net>
Re: new bbs <noreply@gunnar.cc>
Re: Regexp guestion <ppagee@yahoo.com>
Re: Regexp guestion (Peter J. Acklam)
Re: Returning multiple values <invalid-email@rochester.rr.com>
Re: Returning multiple values <jwillmore@remove.adelphia.net>
Re: Returning multiple values <jkrugman@yahbitoo.com>
Template Toolkit Problem (Kevin)
Re: Template Toolkit Problem <nospam@bigpond.com>
Re: Template Toolkit Problem <invalid-email@rochester.rr.com>
Re: Tests fail in cpan, succeed manually <jkrugman@yahbitoo.com>
Re: The value of Truth <wherrera@lynxview.com>
Re: Why are arrays and hashes this way? <xxala_qumsiehxx@xxyahooxx.com>
Re: Why are arrays and hashes this way? <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 Apr 2004 07:48:27 -0500
From: "Chuck" <EatMeSpammers_cwtart@commpay.tv>
Subject: Re: file access trouble
Message-Id: <78bec.906$KG2.1539@reggie.win.bright.net>
Bob,
Tried your suggestion - did not make any difference - my script does not
create the NEW file. Using ActiveState latest version.
--
regards,
Chuck
CommPay Software
"Bob Walton" <invalid-email@rochester.rr.com> wrote in message
news:407849F9.3070500@rochester.rr.com...
> Chuck wrote:
>
> > I am a new user to perl - trying to teach myself enough perl to do a
> > specific task to be used in conjunction with other software I have
> > developed.
> >
> > I am a software developer and use a web site for distribution of the
> > software. The download folder of this web site uses password protection
via
> > .htpasswd
> >
> > I created another windows based program that creates the .htpasswd file
> > locally - each of my software users has their own username and password
to
> > download updates to the software - what I need to do with perl is to
loop
> > through the local .htpasswd file that is created by the other windows
app
> > and crypt() the password. I have already done this by looping through
the
> > local .htpasswd file in my windows based code and copying the password
to be
> > encrypted to the local clipboard on the computer that I use to maintain
my
> > user list. Then I call perl from within my windows based code, get the
data
> > from the clipboard, crypt() the password, and then copy it back to the
> > clipboard, then get the clipboard data in my windows based code, and
update
> > the local .htpasswd file with the encrypted string for the password.
Then
> > after the process is done I use FTP to upload the .htpasswd file to the
> > protected folder on the web server. This all works great but I want to
loop
> > through the entire file using perl rather that calling perl for each
record
> > in the file - this is rather slow because perl needs to be loaded for
each
> > record in the local .htpasswd file rather than only loading once.
> >
> > I have been through several tutorials and did google searches to see if
I
> > could determine why my perl script is not working but could not get it
to
> > work. I ran the script though the perl debugger and made sure there were
no
> > errors in the script that the debugger could find. I am using wperl.exe
so
> > the console window does not show but have also used perl.exe.
> >
> > I have been working on this for a couple of days but figured that some
help
> > from the perl experts could expedite this for me. Any suggestions or
> > pointers will be greatly appreciated.
> >
> > The script runs without any error messages but does not appear to read
data
> > from the already existing .htpasswd file and it does not create the new
> > .htpasswd2 file that I rename to the original file name after the loop
is
> > finished - this is my script;
> >
> > use strict;
> > use warnings;
> >
> > my $text1;
> > my $text2;
> >
> > my $OldFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd";
> > my $NewFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd2";
> >
> > open(OLD, '<', $OldFile) or die "$!\n";
> > open(NEW, '>', $NewFile) or die "$!\n";
> >
> > while (<OLD>) {
> > $text1 = substr($_,0,5);
> > $text2 = crypt(substr($_,5,8),substr($_,13,2));
> > print NEW "$text1 $text2 /n";
>
> \----------------------------^
>
>
> > }
> >
> > close OLD or die "$!\n";
> > close NEW or die "$!\n";
> > rename($NewFile,$OldFile) or die "$!\n";
> ...
>
> Seems to work OK for me, copied verbatim (AS Perl build 806 on Windoze
> 98SE). You might want to consider fixing the /n above that looks like
> you probably intended a \n.
>
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
>
------------------------------
Date: Sun, 11 Apr 2004 04:37:35 GMT
From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: How can this be done?
Message-Id: <jY3ec.50309$Z4.31447@newssvr25.news.prodigy.com>
Uri Guttman wrote:
> gack! stay away from $& and friends. its use will slow down all regexes
> as it forces an extra copy to be saved. just do anormal grab with ().
True. I know about the effect of $& et al, but I thought they were
optimized in recent Perls so that their effect isn't as bad as it used
to be (but still worse than $1 et al). Btw, how much of a penalty does
their use incur? I have never noticed any extra run-time delay due to
their use, and unless you're building a mission-critical app where
real-time response is very important, I doubt any one else will notice
their effect. I might be wrong, but from my experience I don't see any
reason to avoid $& if it makes the code simpler and easier to read
(oxymoron?). Building real-time apps is hardly Perl's niche.
--Ala
------------------------------
Date: Sun, 11 Apr 2004 06:43:47 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How can this be done?
Message-Id: <x7ptafhv4t.fsf@mail.sysarch.com>
>>>>> "AQ" == Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> writes:
AQ> Uri Guttman wrote:
>> gack! stay away from $& and friends. its use will slow down all regexes
>> as it forces an extra copy to be saved. just do anormal grab with ().
AQ> True. I know about the effect of $& et al, but I thought they were
AQ> optimized in recent Perls so that their effect isn't as bad as it
AQ> used to be (but still worse than $1 et al). Btw, how much of a
AQ> penalty does their use incur? I have never noticed any extra
AQ> run-time delay due to their use, and unless you're building a
AQ> mission-critical app where real-time response is very important, I
AQ> doubt any one else will notice their effect. I might be wrong, but
AQ> from my experience I don't see any reason to avoid $& if it makes
AQ> the code simpler and easier to read (oxymoron?). Building
AQ> real-time apps is hardly Perl's niche.
if you want to know the speed penalty, benchmark it. besides that, it is
better code IMO to do an explicit grab than an implict one. even if $&
didn't have a speed issue, i would never use it. as for perl and speed,
you ain't seen my boss who is a perl speed freak. his web template
engine and massive cache (1GB) takes 20 million hits a day. all in
perl. and real time apps don't necessarily have to run that fast. the
key is whether they respond in some way relative to real time. you can
run things with timeouts on the order of seconds and still call it real
time.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 11 Apr 2004 07:14:18 +0100
From: oracle <oracle@r0b3rt.com>
Subject: Is there a way to call Perl/Tk from Apache server
Message-Id: <el5ec.29079$h44.4147042@stones.force9.net>
Hi
I am new to Tk and tried to run a program from Apache.....
It looked good when I ran it from my server! But it only works on my
server....
I have tried to use Xvfb to export the window but just not wining....
I am on a Redhat linux box with Perl 5.8
help please.
Robert
------------------------------
Date: Sun, 11 Apr 2004 03:34:10 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Is there a way to call Perl/Tk from Apache server
Message-Id: <407903ff$0$24340$58c7af7e@news.kabelfoon.nl>
oracle wrote:
> Hi
>
> I am new to Tk and tried to run a program from Apache.....
Err... how do you want to control it? Or do you just want to start it?
> It looked good when I ran it from my server! But it only works on my
> server....
Yes, since you see the window(s).
> I have tried to use Xvfb to export the window but just not wining....
Export to where? Apache can not send a window to the browser. Or do you
want to send a bitmap of the window?
--
John personal page: http://johnbokma.com/
Experienced Perl / Java developer available - http://castleamber.com/
------------------------------
Date: Sun, 11 Apr 2004 10:30:34 +0100
From: oracle <oracle@r0b3rt.com>
Subject: Re: Is there a way to call Perl/Tk from Apache server
Message-Id: <4079103A.5000908@r0b3rt.com>
Thanks John,
What I trying to say is;
If one creates a form using Perl, It can be displayed in a browser.
I was hoping to be able to do the same with the Perl/Tk pogrom too!
Its seems that I need to write PPL and use plug-in....
Or just use Perl.
Unless there is a way to send execute ../cgi-bin/tk-test and send the
GUI to user session....
Robert
John Bokma wrote:
> oracle wrote:
>
>> Hi
>>
>> I am new to Tk and tried to run a program from Apache.....
>
>
> Err... how do you want to control it? Or do you just want to start it?
>
>> It looked good when I ran it from my server! But it only works on my
>> server....
>
>
> Yes, since you see the window(s).
>
>> I have tried to use Xvfb to export the window but just not wining....
>
>
> Export to where? Apache can not send a window to the browser. Or do you
> want to send a bitmap of the window?
>
------------------------------
Date: Sun, 11 Apr 2004 08:53:01 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Is there a way to call Perl/Tk from Apache server
Message-Id: <pan.2004.04.11.12.52.55.573027@remove.adelphia.net>
On Sun, 11 Apr 2004 10:30:34 +0100, oracle wrote:
> What I trying to say is;
>
> If one creates a form using Perl, It can be displayed in a browser. I was
> hoping to be able to do the same with the Perl/Tk pogrom too!
>
> Its seems that I need to write PPL and use plug-in.... Or just use Perl.
>
> Unless there is a way to send execute ../cgi-bin/tk-test and send the GUI
> to user session....
There was a Perl-Tk plugin project that was started some time ago, but I
think it's dead now.
http://sourceforge.net/projects/perlplusplugin/
If nothing else, you may get some ideas from thier project to incorporate
into yours.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
In those days he was wiser than he is now -- he used to
frequently take my advice. -- Winston Churchill
------------------------------
Date: Sun, 11 Apr 2004 20:18:19 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: new bbs
Message-Id: <c5auvg$2q4i4n$1@ID-172104.news.uni-berlin.de>
"Robin" <robin @ infusedlight.net> wrote in message
news:c5ad39$cqo$1@reader2.nmix.net...
> http://www.infusedlight.net/robin/bbs/bbs.pl?action=view
> my latest opus. I hope you like it. I'd like to see if some hacker can
hack
> this baby. I uses cgi.pm and is way more secure.
> Admin script isn't done yet.
Not brave enough to show your code I see.
------------------------------
Date: Sun, 11 Apr 2004 11:29:06 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: new bbs
Message-Id: <c5b3b6$2qkfie$1@ID-184292.news.uni-berlin.de>
Robin wrote:
> I uses cgi.pm and is way more secure.
Using CGI.pm may make the program more flexible and easy to maintain,
but it makes little or no difference with respect to the kind of
security holes your previous versions revealed, even if a few CGI.pm
advocates here love to give another impression.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 11 Apr 2004 12:51:33 +0200
From: Mike Mimic <ppagee@yahoo.com>
Subject: Re: Regexp guestion
Message-Id: <Es9ec.750$37.96701@news.siol.net>
Hi!
Anno Siegel wrote:
> It's hard... How about this:
>
> s< ( { [^}]* } ) >
> < join '', split ' ', $1 >gxe;
And which of those is the fastest?
Mike
------------------------------
Date: 11 Apr 2004 13:24:17 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: Regexp guestion
Message-Id: <zn9izrj2.fsf@online.no>
Mike Mimic <ppagee@yahoo.com> wrote:
> Anno Siegel wrote:
>
> > It's hard... How about this:
> > s< ( { [^}]* } ) >
> > < join '', split ' ', $1 >gxe;
>
> And which of those is the fastest?
perldoc Benchmark
Peter
--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
------------------------------
Date: Sun, 11 Apr 2004 04:24:25 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Returning multiple values
Message-Id: <4078C7FD.2070404@rochester.rr.com>
J Krugman wrote:
> In <4078B667.4050005@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
>
>
>>J Krugman wrote:
>>
>
>>>In <4078A144.7050107@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
>>>
>>>
>>>
>>>>J Krugman wrote:
>>>>
>>...
>>
>>>OK, but what does it mean? What does perl do when it executes the
>>>statement
>>>
>>> () = (7, 8, 9);
>>>
>
>>>? Does the above evaluate to some sort of anonymous array?
>>>
>
>
>>Look it up:
>>
>
>> perldoc perldata
>>
>
>>in the "List value constructors" section.
>>
>
> OK, I read that section, but it says nothing whatsoever about
> assigning to ().
>
> Does anybody know what Perl does when one assigns a list to () (as
> shown above)?
Here is the relevant section from perldata, which explicitly discuss the
assignment
$n=()=$somevar=~/some pattern/g;
which is just like:
$n=()=(7,8,9);
from a basic perspective, with the () acting to force a list-context
evaluation of the right-hand-side of the second = :
"An exception to this [assignment to a list of lvalues] is that you may
assign to undef in a list. This is useful for throwing away some of the
return values of a function:
($dev, $ino, undef, undef, $uid, $gid) = stat($file);
List assignment in scalar context returns the number of elements
produced by the expression on the right side of the assignment:
$x = (($foo,$bar) = (3,2,1)); # set $x to 3, not 2
$x = (($foo,$bar) = f()); # set $x to f()'s return count
This is handy when you want to do a list assignment in a Boolean
context, because most list functions return a null list when finished,
which when assigned produces a 0, which is interpreted as FALSE.
It's also the source of a useful idiom for executing a function or
performing an operation in list context and then counting the number of
return values, by assigning to an empty list and then using that
assignment in scalar context. For example, this code:
$count = () = $string =~ /\d+/g;
will place into $count the number of digit groups found in $string. This
happens because the pattern match is in list context (since it is being
assigned to the empty list), and will therefore return a list of all
matching parts of the string. The list assignment in scalar context will
translate that into the number of elements (here, the number of times
the pattern matched) and assign that to $count. Note that simply using
$count = $string =~ /\d+/g;
would not have worked, since a pattern match in scalar context will only
return true or false, rather than a count of matches."
...
> jill
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sun, 11 Apr 2004 00:34:17 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Returning multiple values
Message-Id: <pan.2004.04.11.04.34.10.572554@remove.adelphia.net>
On Sun, 11 Apr 2004 03:53:40 +0000, J Krugman wrote:
> In <4078B667.4050005@rochester.rr.com> Bob Walton
> <invalid-email@rochester.rr.com> writes:
>
>>J Krugman wrote:
>
>>> In <4078A144.7050107@rochester.rr.com> Bob Walton
>>> <invalid-email@rochester.rr.com> writes:
>>>
>>>
>>>>J Krugman wrote:
>>...
>>> OK, but what does it mean? What does perl do when it executes the
>>> statement
>>>
>>> () = (7, 8, 9);
>
>
>>> ? Does the above evaluate to some sort of anonymous array?
>
>
>>Look it up:
>
>> perldoc perldata
>
>>in the "List value constructors" section.
>
> OK, I read that section, but it says nothing whatsoever about assigning to
> ().
>
> Does anybody know what Perl does when one assigns a list to () (as shown
> above)?
from perldoc perldata ("List value constructors")
...
It's also the source of a useful idiom for executing a
function or performing an operation in list context and
then counting the number of return values, by assigning to
an empty list and then using that assignment in scalar
context. For example, this code:
$count = () = $string =~ /\d+/g;
will place into $count the number of digit groups found in
$string. This happens because the pattern match is in
list context (since it is being assigned to the empty
list), and will therefore return a list of all matching
parts of the string. The list assignment in scalar context
will translate that into the number of elements (here, the
number of times the pattern matched) and assign that to
$count.
...
You're assigning the return value of the subroutine to an empty list and
it's being evaluated as such (a list).
So,
my $n=()=foo();
the return value(s) of sub foo will go into the empty list (and populate
it). Because you're evaluating a list in scalar context, you'll get the
number of values in the list :-) If you do:
my $n=foo();
You'll get the last value, as demonstrated by the following one liner:
jim@maxine:~> perl -e 'sub x{ qw(a b c d) };$count = x();print "$count\n"'
d
jim@maxine:~>
instead of
jim@maxine:~> perl -e 'sub x{ qw(a b c d) };$count = () = x();print "$count\n"'
4
jim@maxine:~>
which is what you wanted.
I used 'qw' to demonstrate what's going on. Using numbers, IMHO, clouds
the issue.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Ed Sullivan will be around as long as someone else has talent.
-- Fred Allen
------------------------------
Date: Sun, 11 Apr 2004 11:09:26 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Returning multiple values
Message-Id: <c5b916$s69$1@reader1.panix.com>
In <4078C7FD.2070404@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
>J Krugman wrote:
>> In <4078B667.4050005@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
>>
>>
>>>J Krugman wrote:
>>>
>>
>>>>In <4078A144.7050107@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
>>>>
>>>>
>>>>
>>>>>J Krugman wrote:
>>>>>
>>>...
>>>
>>>>OK, but what does it mean? What does perl do when it executes the
>>>>statement
>>>>
>>>> () = (7, 8, 9);
>>>>
>>
>>>>? Does the above evaluate to some sort of anonymous array?
>>>>
>>
>>
>>>Look it up:
>>>
>>
>>> perldoc perldata
>>>
>>
>>>in the "List value constructors" section.
>>>
>>
>> OK, I read that section, but it says nothing whatsoever about
>> assigning to ().
>>
>> Does anybody know what Perl does when one assigns a list to () (as
>> shown above)?
>Here is the relevant section from perldata, which explicitly discuss the
>assignment
> $n=()=$somevar=~/some pattern/g;
>which is just like:
> $n=()=(7,8,9);
>from a basic perspective, with the () acting to force a list-context
>evaluation of the right-hand-side of the second = :
>"An exception to this [assignment to a list of lvalues] is that you may
>assign to undef in a list. This is useful for throwing away some of the
>return values of a function:
> ($dev, $ino, undef, undef, $uid, $gid) = stat($file);
>List assignment in scalar context returns the number of elements
>produced by the expression on the right side of the assignment:
> $x = (($foo,$bar) = (3,2,1)); # set $x to 3, not 2
> $x = (($foo,$bar) = f()); # set $x to f()'s return count
>This is handy when you want to do a list assignment in a Boolean
>context, because most list functions return a null list when finished,
>which when assigned produces a 0, which is interpreted as FALSE.
>It's also the source of a useful idiom for executing a function or
>performing an operation in list context and then counting the number of
>return values, by assigning to an empty list and then using that
>assignment in scalar context. For example, this code:
> $count = () = $string =~ /\d+/g;
>will place into $count the number of digit groups found in $string. This
>happens because the pattern match is in list context (since it is being
>assigned to the empty list), and will therefore return a list of all
>matching parts of the string. The list assignment in scalar context will
>translate that into the number of elements (here, the number of times
>the pattern matched) and assign that to $count. Note that simply using
> $count = $string =~ /\d+/g;
>would not have worked, since a pattern match in scalar context will only
>return true or false, rather than a count of matches."
>...
Thanks. I've discovered that my perldata page is damaged goods:
List assignment in scalar context returns the number of
elements produced by the expression on the right side of
the assignment:
$x = (($foo,$bar) = (3,2,1)); # set $x to 3, not 2
$x = (($foo,$bar) = f()); # set $x to f()'s return count
This is handy when you want to do a list assignment in a
Boolean context, because most list functions return a null
list when finished, which when assigned produces a 0,
which is interpreted as FALSE.
The final element may be an array or a hash:
($a, $b, @rest) = split;
my($a, $b, %rest) = @_;
You can actually put an array or hash anywhere in the
...
It is not that old either (2003-09-11). This is unsettling.
jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
Date: 10 Apr 2004 21:47:02 -0700
From: kkinderen@earthlink.net (Kevin)
Subject: Template Toolkit Problem
Message-Id: <56f89c08.0404102047.17645197@posting.google.com>
I'm getting a Server error - malformed header from script. Bad
header=<html>: template.pl when running a very simple example of
the template toolkit. When I run the script, and redirect output to a
file (.html) it opens nicely in a browser.
Strange it shows < and >
Output from the script is:
<html>
<head><title>Template Toolkit @TPC4</title></head>
<body bgcolor="#ffffff">
<h1>Hello World!</h1>
<p>The Cat Sat on the Mat</p>
</body>
</html>
Here's what I've got:
template.pl
-----------
#!/usr/bin/perl -w
use strict;
use Template;
my $template = Template->new({
INCLUDE_PATH => './templates',
});
my $file = 'welcome.html';
my $vars = {
message => 'The Cat Sat on the Mat',
};
$template->process($file, $vars)
|| die $template->error(), "\n";
templates/header
----------------
<html>
<head><title>[% title %]</title></head>
<body bgcolor="#ffffff">
templates/footer
----------------
</body>
</html>
Any help would be appreciated.
Kevin
------------------------------
Date: Sun, 11 Apr 2004 15:18:55 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Template Toolkit Problem
Message-Id: <6330333.hpJeSVEZFG@GMT-hosting-and-pickle-farming>
Kevin wrote:
> I'm getting a Server error - malformed header
Are you sending a Content-Type ??
gtoomey
------------------------------
Date: Sun, 11 Apr 2004 05:27:11 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Template Toolkit Problem
Message-Id: <4078D6AE.9040807@rochester.rr.com>
Kevin wrote:
> I'm getting a Server error - malformed header from script. Bad
> header=<html>: template.pl when running a very simple example of
> the template toolkit. When I run the script, and redirect output to a
> file (.html) it opens nicely in a browser.
>
> Strange it shows < and >
>
> Output from the script is:
>
> <html>
> <head><title>Template Toolkit @TPC4</title></head>
>
> <body bgcolor="#ffffff">
>
>
>
> <h1>Hello World!</h1>
>
> <p>The Cat Sat on the Mat</p>
>
> </body>
> </html>
>
>
> Here's what I've got:
>
> template.pl
> -----------
> #!/usr/bin/perl -w
>
> use strict;
> use Template;
>
> my $template = Template->new({
> INCLUDE_PATH => './templates',
> });
>
> my $file = 'welcome.html';
> my $vars = {
> message => 'The Cat Sat on the Mat',
> };
>
> $template->process($file, $vars)
> || die $template->error(), "\n";
>
>
> templates/header
> ----------------
> <html>
> <head><title>[% title %]</title></head>
>
> <body bgcolor="#ffffff">
>
>
> templates/footer
> ----------------
> </body>
> </html>
...
> Kevin
This is a FAQ:
perldoc -q 500
You're not generating a HTTP header, which is what your server is trying
to tell you with the error message it gives. And you don't:
use CGI;
which just makes life harder for you.
CGI questions like this (you would have had the same problem if your
script was written in any other language, so it's not a Perl problem)
should be referred to a CGI newsgroup.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sun, 11 Apr 2004 11:18:34 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Tests fail in cpan, succeed manually
Message-Id: <c5b9ia$s69$2@reader1.panix.com>
In <196cb7af.0404101754.542e0d3f@posting.google.com> jkeen_via_google@yahoo.com (Jim Keenan) writes:
>J Krugman <jkrugman@yahbitoo.com> wrote in message news:<c59d3j$bk3$1@reader1.panix.com>...
>> In <pan.2004.04.10.16.24.30.113130@remove.adelphia.net> James Willmore <jwillmore@remove.adelphia.net> writes:
>>
>> >On Sat, 10 Apr 2004 15:42:05 +0000, J Krugman wrote:
>> >> I'm trying to understand what's going on, and decide what to do. When I
>> >> attemptto install the module XML::Validator::Schema via CPAN.pm, all
>> >> attempted tests fail:
>> >>
>The module's author recommends this mailing list for support:
>http://listserv.activestate.com/mailman/listinfo/perl-xml
>Have you tried that yet?
Yes, long ago. I'm still waiting to get my request to join the
list approved.
jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
Date: Sun, 11 Apr 2004 00:14:16 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: The value of Truth
Message-Id: <xLCdnb29MJygf-XdRVn-ig@adelphia.com>
kj wrote:
> The if procedure Test::ok is given 3 arguments, it evaluates the
> first 2 arguments, tests to see if they are equal (using eq), and
> prints a message involving the 3rd argument if they are not.
>
> Supposing that we wanted a test that succeeded if foo() > 0, and
> having the message upon failure contain the string "bad foo". One
> could use something like ok(foo() > 0, 1, 'bad foo'), on the
> assumption that if foo() > 0 was true it would evaluate to 1.
>
> I remember reading somewhere that it was bad form to assume any
> particular value for a truth value in Perl, because the implementation
> reserved the right to change this value.
Yes, but for a given perl script run, it will not change the way they
are talking about. That would be something well defined by the time the
program is compiled. So---
If you are using the basic module Test.pm, the ok(arg1, arg2, arg3)
function type does a string eq type compare between arg1 and arg2 and
succeeds, I guess, if scalar arg1 eq scalar arg2. So don't worry about
what 'true' is. just do this:
ok(foo() > 0, 1 > 0, 'bad foo'); # will always be ok if foo() > 0
Also, for most complicated tests, consider Test::More since it allows
more varied constructs and so lets you avoid syntax convolutions like
that one.
-hth
------------------------------
Date: Sun, 11 Apr 2004 04:41:55 GMT
From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <n04ec.50310$76.37628@newssvr25.news.prodigy.com>
Xavier Noria wrote:
> Does anybody know why structures were designed so that they could just
> hold scalars?
AFAIK, that was how Larry Wall originally designed it, and it stayed
this way for backward compatibility. The introduction of reference with
Perl5 was specifically targeted at adding the ability to build nested
data structures.
--Ala
------------------------------
Date: Sun, 11 Apr 2004 06:47:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <x7n05jhuyo.fsf@mail.sysarch.com>
>>>>> "AQ" == Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> writes:
AQ> Xavier Noria wrote:
>> Does anybody know why structures were designed so that they could just
>> hold scalars?
AQ> AFAIK, that was how Larry Wall originally designed it, and it stayed
AQ> this way for backward compatibility. The introduction of reference
AQ> with Perl5 was specifically targeted at adding the ability to build
AQ> nested data structures.
and even without that, it makes very good sense. the problem with
storing a real hash where a scalar is, is how do you store it? the slot
in an SV can hold a single item (a scalar) so what would you put there
to represent a hash? and if any of those hash elements was a hash, all
memory hell breaks out. in c, you can only do multidim arrays of known
element size. with perl you can have each thing at any level be any
thing of any size. so the win is major flexibility at a cost of
understanding and dealing with refs. not a bad tradeoff IMO.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
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 6385
***************************************