Re: how to include a file

2002-03-18 Thread Kee Hinckley

At 6:35 PM -0600 3/17/02, Puneet Kishor wrote:
>I am glad I asked, because I just spent a good part of last night 
>setting up Mason. I can't get it to work correctly because my 
>mod_perl is buggered up (my previous emails ask for help on that 
>issue), but I have got it working as a

That particular message shouldn't interfere with most operations (my 
Perl is running that way as well, I haven't got around to setting the 
language in the startup scripts, I keep hoping Apple will release the 
correct patches for Perl).

>CGI (being called via handler.pl). So, I have one vote for Mason, 
>and now one vote for Embperl... choice is good, but choice is also 
>confusing... but heck, that _is_ the Perl way, no :-)
>
>I will give Embperl a go now and see how it compares to Mason.

The Embperl mailing list is quite active, and support there is quite 
good.  However the main reason I like Embperl (aside from 2.0, which 
allows you to embed Perl in just about anything) is that it 
understands the syntax of the language.  That means that filling in a 
form, for instance, from a database lookup is a matter of setting the 
%fdat hash to the values from the database, and Embperl handles 
filling in all of the form values.  It understands how to loop in 
pulldown menus and fill in the correct values for all the choices. 
And very importantly (from a security standpoint) it understands how 
to escape output.  So that [+ $foo +] will be  HTML escaped, 
but  will be URL escaped.

I just find that it saves me a lot of programming work.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
[EMAIL PROTECTED]

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.



Re: how to include a file

2002-03-18 Thread Ray Zimmerman

At 6:35 PM -0600 3/17/02, Puneet Kishor wrote:
>I guess it is a matter of getting used to one way of doing things 
>versus another. I actually find it very easy if everything goes 
>through the one bottleneck of index.???. Esp. useful if I am 
>building in extensive error-trapping on an application level, or if 
>I want to change the look and feel of the application globally. One 
>downside is that the URLs are cryptic (actually not so, since every 
>call has a hint to what is going to be done via the index file, for 
>eg, index.pl?do=getrecords or index.pl?do=insertrecords, etc.), but 
>mnemonic URLs are not important in an application anyway.

Have a look at autohandlers and dhandlers in Mason. I think a 
top-level autohandler is probably what you want to take the place of 
your index.pl.

-- 
  Ray Zimmerman  / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall
   Sr Research  /   phone: (607) 255-9645  /  Cornell University
Associate  /  FAX: (815) 377-3932 /   Ithaca, NY  14853



Re: how to include a file

2002-03-18 Thread Adam Witney


On the subject of Embperl, I have been trying to install HTML-Embperl-1.3.4,
however the tests fail Any help would be greatly appreciated? (perl
5.6.0)

[mrc1-003:local/install/HTML-Embperl-1.3.4] adam% make test
PERL_DL_NONLAZY=0 /usr/local/bin/perl -Iblib/arch -Iblib/lib
-I/System/Library/Perl/darwin -I/System/Library/Perl test.pl

loading...dyld: /usr/local/bin/perl Undefined symbols:
_ap_add_module
_ap_add_version_component
_ap_get_client_block
_ap_log_error
_ap_make_sub_pool
_ap_palloc
_ap_pstrdup
_ap_register_cleanup
_ap_remove_module
_ap_rflush
_ap_rputc
_ap_rwrite
_ap_send_http_header
_ap_set_content_length
_ap_setup_client_block
_ap_should_client_block
_ap_table_add
_ap_table_get
_ap_table_set
make: *** [test_dynamic] Error 67




Re: how to include a file

2002-03-17 Thread Pete Prodoehl


That downside could easily be fixed thought the use of mod_rewrite, 
no? But as you say, it may not be as important for an application...

Pete

>  One downside is that the URLs are cryptic (actually not so, since 
>every call has a hint to what is going to be done via the index 
>file, for eg, index.pl?do=getrecords or index.pl?do=insertrecords, 
>etc.), but mnemonic URLs are not important in an application anyway.




Re: how to include a file

2002-03-17 Thread Puneet Kishor


On Sunday, March 17, 2002, at 09:26  AM, Kee Hinckley wrote:

> Using Embperl's EmbperlObject model you could do this automatically in 
> a readable fashion.  Loading "login" would wrap it in a top-level 
> template automatically.  Or alternatively you could have "login.html" 
> include "index.pl" and then call the appropriate routines at the 
> appropriate places.
>
> The other big advantage you'll get using a package like HTML::Embperl 
> over doing it yourself with .pl files is caching.  The perl files will 
> get compiled once, and then the code will be reused.  You also don't 
> have to worry about cross-site scripting security issues, since Embperl 
> always escapes user's input appropriately for the context.
>

>
> After several years using my own embedded perl scripting solution I 
> took a close look at Mason and Embperl and went with Embperl.  It's 
> been several years more now, and with the XML support being added in 
> Embperl 2.0, I'm feeling very good about that solution.  Other's might 
> prefer Mason.  But I would definitely recommend either package over 
> straight CGI and home-brew templates.
>

I am glad I asked, because I just spent a good part of last night 
setting up Mason. I can't get it to work correctly because my mod_perl 
is buggered up (my previous emails ask for help on that issue), but I 
have got it working as a CGI (being called via handler.pl). So, I have 
one vote for Mason, and now one vote for Embperl... choice is good, but 
choice is also confusing... but heck, that _is_ the Perl way, no :-)

I will give Embperl a go now and see how it compares to Mason.

> At 7:37 PM -0600 3/16/02, Puneet Kishor wrote:
>> I have one index.pl (this is a web app), and everything passes through 
>> this. So, if the call is to index.pl?do=login then the login page is 
>> included, if the call is to index.pl?do=verify then the verify page is 
>> included. This is how I work in the world of other web programming 
>> (Cold Fusion, PHP, etc.).
>
> I've never understood why I see so much Coldfusion code doing it this 
> way.  Coming in and debugging other people's code I find it very 
> difficult to figure out what is getting executed when with this model.


I guess it is a matter of getting used to one way of doing things versus 
another. I actually find it very easy if everything goes through the one 
bottleneck of index.???. Esp. useful if I am building in extensive 
error-trapping on an application level, or if I want to change the look 
and feel of the application globally. One downside is that the URLs are 
cryptic (actually not so, since every call has a hint to what is going 
to be done via the index file, for eg, index.pl?do=getrecords or 
index.pl?do=insertrecords, etc.), but mnemonic URLs are not important in 
an application anyway.




Re: how to include a file

2002-03-17 Thread Kee Hinckley

At 7:37 PM -0600 3/16/02, Puneet Kishor wrote:
>I have one index.pl (this is a web app), and everything passes 
>through this. So, if the call is to index.pl?do=login then the login 
>page is included, if the call is to index.pl?do=verify then the 
>verify page is included. This is how I work in the world of other 
>web programming (Cold Fusion, PHP, etc.).

I've never understood why I see so much Coldfusion code doing it this 
way.  Coming in and debugging other people's code I find it very 
difficult to figure out what is getting executed when with this model.

Using Embperl's EmbperlObject model you could do this automatically 
in a readable fashion.  Loading "login" would wrap it in a top-level 
template automatically.  Or alternatively you could have "login.html" 
include "index.pl" and then call the appropriate routines at the 
appropriate places.

The other big advantage you'll get using a package like HTML::Embperl 
over doing it yourself with .pl files is caching.  The perl files 
will get compiled once, and then the code will be reused.  You also 
don't have to worry about cross-site scripting security issues, since 
Embperl always escapes user's input appropriately for the context.

>-- is there anything wrong with coveting embperl, any downsides? Are 
>there other ways of doing things?

After several years using my own embedded perl scripting solution I 
took a close look at Mason and Embperl and went with Embperl.  It's 
been several years more now, and with the XML support being added in 
Embperl 2.0, I'm feeling very good about that solution.  Other's 
might prefer Mason.  But I would definitely recommend either package 
over straight CGI and home-brew templates.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
[EMAIL PROTECTED]

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.



Re: how to include a file

2002-03-16 Thread Puneet Kishor


On Saturday, March 16, 2002, at 10:49  PM, Michael Maibaum wrote:
>> On another note... I saw that the mod_perl lines were commented out in
>> my httpd.conf. Since mod_perl is required for Mason (well, Mason
>> performs best with mod_perl), I uncommented the mod_perl lines. Now
>> httpd won't start. I get the following error when I tail my error_log
>
> Well, the stock apache (with stock perl) and stock mod_perl work fine.

well, when I got my iBook it had the stock apache with stock perl on it, 
but I never activated the stock mod_perl (if it was there... I didn't 
check).

> It looks like you updated the perl on your machine...I recompiled
> mod_perl and apache when I upgraded my perl

Yes, I updated Perl to 5.6.1, and mod_perl and Apache using Ray 
Zimmerman's steps oft quoted on this and other lists. My results were 
the same as his (and many others) but for some reason I did not have any 
success with mod_perl. I guess I had disabled mod_perl and forgotten all 
about it. So, when I included it in this evening it Apache croaked with 
the following message...


>> perl: warning: Setting locale failed.
>> perl: warning: Please check that your locale settings:
>> LC_ALL = (unset),
>> LANG = "en_US"
>> are supported and installed on your system.
>> perl: warning: Falling back to the standard locale ("C").
>
> This is a fairly minor issue, set LC_ALL to LC_ALL=C in the system
> startup scripts, but this error shouldn't break anything.

I remember something about this... I think I used to get this error 
everytime I would run perl in the Terminal, and then I used the SETENV 
command once to set the locale settings and I haven't experienced this 
error since in the Terminal. This is the first time I am seeing this in 
the error_log when trying to start Apache. I guess it seems Apache is 
not recognizing the locale settings that the Terminal recognizes.

>> Looks like I have made a bigger mess than I was in.
> Was apache working before this? Anything else in the error log?

Yes, Apache works fine (and so does Perl) as long as I comment out the 
mod_perl load lines in httpd.conf. Only when I try to start Apache with 
mod_perl is that it croaks. Also, there are no syntax errors in my 
httpd.conf (at least according to apachectl configtest). I guess I have 
to make Apache recognize the locale settings, no? How do I do that for 
the entire system, preferably automatically when the system starts?

Thanks for the guidance,

pk/




Re: how to include a file

2002-03-16 Thread Michael Maibaum

On Sat, Mar 16, 2002 at 10:30:44PM -0600, Puneet Kishor wrote:
> Michael, Thanks for the Mason tip. It does look exactly like what I 
> need. Although I wonder how it compares with embperl... anyone any 
> thoughts?
I don't really know embperl well, so I'll leave that to someone else..
> 
> On another note... I saw that the mod_perl lines were commented out in 
> my httpd.conf. Since mod_perl is required for Mason (well, Mason 
> performs best with mod_perl), I uncommented the mod_perl lines. Now 
> httpd won't start. I get the following error when I tail my error_log

Well, the stock apache (with stock perl) and stock mod_perl work fine.

It looks like you updated the perl on your machine...I recompiled
mod_perl and apache when I upgraded my perl
> 
> perl: warning: Setting locale failed.
> perl: warning: Please check that your locale settings:
> LC_ALL = (unset),
> LANG = "en_US"
> are supported and installed on your system.
> perl: warning: Falling back to the standard locale ("C").

This is a fairly minor issue, set LC_ALL to LC_ALL=C in the system
startup scripts, but this error shouldn't break anything.

For me, when I upgraded perl, mod_perl would crash apache until I
recompiled it.
> 
> Looks like I have made a bigger mess than I was in.
Was apache working before this? Anything else in the error log?
> 
> Please help, someone.

I imagine someone more expert than I could have something to add...
Michael
-- 
Dr Michael A. Maibaum - (W)+1 (415) 561 1682 - (H)+1 (415) 626 6733
<[EMAIL PROTECTED]> http://www.gene-hacker.net/>



Re: how to include a file

2002-03-16 Thread Puneet Kishor

Michael, Thanks for the Mason tip. It does look exactly like what I 
need. Although I wonder how it compares with embperl... anyone any 
thoughts?

On another note... I saw that the mod_perl lines were commented out in 
my httpd.conf. Since mod_perl is required for Mason (well, Mason 
performs best with mod_perl), I uncommented the mod_perl lines. Now 
httpd won't start. I get the following error when I tail my error_log

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LC_ALL = (unset),
 LANG = "en_US"
 are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Looks like I have made a bigger mess than I was in.

Please help, someone.

pk/



On Saturday, March 16, 2002, at 09:24  PM, Michael Maibaum wrote:

> On Sat, Mar 16, 2002 at 07:37:18PM -0600, Puneet Kishor wrote:
>> question from a newbie. How do I include a code fragment in a perl
>> script so it first gets included and then interpreted/compiled?
>>
>> Ok. that's the short question. In other words, this is what I am trying
>> to do --
>>
>> I have one index.pl (this is a web app), and everything passes through
>> this. So, if the call is to index.pl?do=login then the login page is
>> included, if the call is to index.pl?do=verify then the verify page is
>> included. This is how I work in the world of other web programming 
>> (Cold
>> Fusion, PHP, etc.). This way I have to declare all my use statements 
>> (to
>> import packages), other declarations, param checking, etc. in one 
>> place.
>> I also have one master template, and everything else is simply
>> included...
>
> look at HTML::Mason, you will like it :).
> 
>
> HTH
>
> Michael
> --
> Dr Michael A. Maibaum - (W)+1 (415) 561 1682 - (H)+1 (415) 626 6733
> <[EMAIL PROTECTED]> http://www.gene-hacker.net/>




Re: how to include a file

2002-03-16 Thread Michael Maibaum

On Sat, Mar 16, 2002 at 07:37:18PM -0600, Puneet Kishor wrote:
> question from a newbie. How do I include a code fragment in a perl 
> script so it first gets included and then interpreted/compiled?
> 
> Ok. that's the short question. In other words, this is what I am trying 
> to do --
> 
> I have one index.pl (this is a web app), and everything passes through 
> this. So, if the call is to index.pl?do=login then the login page is 
> included, if the call is to index.pl?do=verify then the verify page is 
> included. This is how I work in the world of other web programming (Cold 
> Fusion, PHP, etc.). This way I have to declare all my use statements (to 
> import packages), other declarations, param checking, etc. in one place. 
> I also have one master template, and everything else is simply 
> included...

look at HTML::Mason, you will like it :).


HTH

Michael
-- 
Dr Michael A. Maibaum - (W)+1 (415) 561 1682 - (H)+1 (415) 626 6733
<[EMAIL PROTECTED]> http://www.gene-hacker.net/>



how to include a file

2002-03-16 Thread Puneet Kishor

question from a newbie. How do I include a code fragment in a perl 
script so it first gets included and then interpreted/compiled?

Ok. that's the short question. In other words, this is what I am trying 
to do --

I have one index.pl (this is a web app), and everything passes through 
this. So, if the call is to index.pl?do=login then the login page is 
included, if the call is to index.pl?do=verify then the verify page is 
included. This is how I work in the world of other web programming (Cold 
Fusion, PHP, etc.). This way I have to declare all my use statements (to 
import packages), other declarations, param checking, etc. in one place. 
I also have one master template, and everything else is simply 
included...

bunch of perl
html html html

require $do;

html html html


Except, if I do "require" then $do is evaluated outside this page, and 
hence doesn't get any of the local variables. What am I not aware of 
here?

On more general terms I need some advice. Although I have been building 
web applications for several years now, I have discovered the joy of 
Perl only recently (few months) and am totally enamored by it. I don't 
really want to get good at CGI.pm because it is simply a replacement for 
the html abomination, but since I am used to the html abomination, 
CGI.pm is basically a pain in the derriere for me. I miss the 
embeddability of other languages, so it makes me covet embperl. 
Question -- is there anything wrong with coveting embperl, any 
downsides? Are there other ways of doing things?

tia,

pk/