CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Dinamic Pages

 



varo
stranger

Jul 31, 2001, 9:33 AM

Post #1 of 8 (2477 views)
Dinamic Pages Can't Post

I am using the cgi.pm package to create dinamic pages from my perl cgi.

In this page that I create, I whant to include a perlscript. How do I this. I aslo need that the perscipt code to be invisible in the source of the page.

thanks
alvaro



mhx
Enthusiast / Moderator

Jul 31, 2001, 9:54 AM

Post #2 of 8 (2475 views)
Re: Dinamic Pages [In reply to] Can't Post

I can only guess what you are talking about, and if I guess right, it's not possible.
A web page made up of HTML is always visible. You cannot make anything invisible. Additionally, you could include a Perl script, but how would you want to execute it?
And besides, what would be the need of a Perl script included in a HTML page?
I'm quite sure if you would describe your problem in more detail than "wanting to include a Perl script in a web page", there'll sure be a solution. Just describe what exaclty you want to do.

-- Marcus


Code
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= 
($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"



randor
User

Jul 31, 2001, 2:31 PM

Post #3 of 8 (2468 views)
Re: Dinamic Pages [In reply to] Can't Post

ps: if you want a dYnamic webpage.. i personally sugjest writing your own code, as i find cgi.pm to be a waste of time, i know i will get alot of slack from this, but modules (90% of them) are more trouble than they are worth.. plus, with using them you do NOT learn to write perl, but instead just learn to use shortcuts, and shortcuts spawn laziness, (btw i am not in any way implying that you are lazy, but it in general promotes it).

any way, this is my 2 cents on the deal, i do not expect people to understand my thoughts, but it would be interesting to hear yours...


I Hope this helps...

perl programmers don't die.. they just start writing a new script.


checkmate2001
stranger

Jul 31, 2001, 6:05 PM

Post #4 of 8 (2464 views)
Re: Dinamic Pages [In reply to] Can't Post

hi, varo
I wonder if you are referring to the client side perlscript,
something like
<script language=PerlScript>
</script>?

If so, you may have to try to find some encrption utility to do it. Microsoft provide a client side script encoder, but it can be only applied to JavaScript or VBScript.

Good luck.





Jasmine
Administrator / Moderator

Aug 1, 2001, 8:03 PM

Post #5 of 8 (2449 views)
Re: Dinamic Pages [In reply to] Can't Post

randor,

As you surmised, yes, you have some opposition to not using modules where available. Using CGI.pm does not prevent you from learning Perl. However, using CGI.pm foregoes the need for you to learn HTML and write substandard (and perhaps buggy) code. How many times I've seen buggy (even dangerous) handrolled work is a testament to this.

CGI.pm is simply a facilitator to writing proper html code for your CGI output, among other things.

I don't know about you, but when I was first trying to incorporate raw html code into my cgi scripts, I wondered why the pages didn't look right in Netscape. Unless you don't mind making your code 10x longer with html code, unless you like digging through your combined perl/html code to figure out why something doesn't look right, and unless you don't mind re-doing your html in your cgi program to make it comply with the lastest standards, there's no need to use CGI.pm.

Also, if a module is well written, there are no changes (only enhancements) to accessing a module's methods. This means that regardless of what may change, your program will continue to work as long as you have the most current version of the module. Far better than digging through lines upon lines of code of something you don't understand when something changes.

For example, if you used CGI.pm two years ago, you wouldn't have to update a single thing today to make it xhtml compliant (automatically updated with new CGI.pm version). If you didn't and you need to make your code xhtml compliant, you'd need to dig through every line of your html code to update it.

Why reinvent the wheel? Focus on what your programs need to do and use modules, when available for your specialized task, do the background work. That's not laziness, that's efficient programming.




randor
User

Aug 2, 2001, 2:36 PM

Post #6 of 8 (2442 views)
Re: Dinamic Pages [In reply to] Can't Post

Jasmine,

Yes, you have good points on your statements, but i must still stand by my statement, as in everything you do, there is the good and the bad. for me personally, i do not mind rewriting html if need be, and i like the fact that I have the control over what the html looks like, not just calling a sub routine and letting the mod add it. another down side to modules is the waste of resources, lets again take a look at cgi.pm, lets say that i need just 1 textbox on a page that posts to script.cgi, now, if i was to use cgi.pm i would be using a LARGE module for 1 function, and i would be "taking the hit" of the module. but if i just write it out, then there is no wasted memory for the module. And the fact that i do not use modules (most of them) i do know how to write html, and if i did use mod's i would say that it is pretty certain that i would not know how to write html.
that is more of my view on that.

PLEASE do not think i am starting a fight or looking to argue, as i truly feel that these type of conversations are helpful and needed. I respect your thought and do wish to hear them, and i also learn from these type of posts.

Thank you,
Randor

I Hope this helps...

perl programmers don't die.. they just start writing a new script.


Jasmine
Administrator / Moderator

Aug 2, 2001, 9:28 PM

Post #7 of 8 (2437 views)
Re: Dinamic Pages [In reply to] Can't Post

I didn't think you were looking to start an argument :)

Before I rehash things already discussed, you may want want to take a look at this thread. It sums up my standpoint on CGI.pm more completely, and offers opposite opinions.


In Reply To
lets say that i need just 1 textbox on a page that posts to script.cgi

Not to stir anything up, this is a prime example on why people think CGI.pm is bloat. But, if you're creating a textbox, you're creating a form, if you're creating a form, you're creating a web page, and if you're creating a web page, you're including a nice chunk of html code.

So, for example, you're writing:


Code
print <<EOF; 
Content-type: text/html\n\n

<HTML>
<HEAD>
<TITLE>This is a page</TITLE>
<BODY BGCOLOR="white">
</HEAD>

<H1>Fill out my cool form!</H1>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<INPUT TYPE="TEXT" NAME="me">
<INPUT TYPE="SUBMIT" VALUE="Click me">
</FORM>

<P>Thanks for filling out my feedback form!</P>

</BODY>
</HTML>

and the code yields exactly what's displayed. I can use something like this:


Code
use CGI qw /:standard/; 

print
header(),
start_html( -title => 'This is a page', -bgcolor => 'white' ),

h1( 'Fill out my cool form!' ),

start_form( -method => 'post', -action => self_url() ),
textfield( -name => 'me' ),
submit( -label => 'Click me' ),
end_form(),

p( 'Thanks for filling out my feedback form!' ),

end_html();

and get ugly html code, but that ugly code can be w3c validated without an error or warning (assuming CGI.pm is used to output ALL of your html code and you don't cheat :). Not to mention, xhtml compliant.

I hope this somehow showed that there's no such thing as "just a text field" when doing cgi stuff. If it seems to be overkill to just use one or two functions, then it's just not fully understanding what CGI.pm can do. 99% of every stitch of html output can be generated by CGI.pm. For example, just consider how you would do the following simple program without CGI.pm...


Code
use CGI qw /:standard/; 

my $in = CGI->new(); # parse input

print
header(),
start_html( -title => 'This is a page', -bgcolor => 'white' ),
greeting(),
end_html();


sub greeting {
if ( !$in->param('field1') ){
return
h1( "What's the secret name?" ) , output_form();
}
elsif ( $in->param('field1') ne 'Jasmine' ){
return
h1( "Wrong! What's the secret name?" ) , output_form();
}
else {
return h1( 'You guessed correctly!' );
}
}

sub output_form{
return
start_form( -method => 'post', -action => self_url() ),
$in->textfield( -name => 'field1' ),
submit( -label => 'Enter Guess' ),
end_form();

# The $in-> preceeding the methods "remember" what the
# last guess was without without the need for an if .. else
# test. Sticky.
}

Sure, CGI.pm's html code output is horrendous, but when I'm programming, I really don't care if people think my html source code is pretty. Quite to the contrary, sometimes you don't want it to be easy to show code.

It's late... so I babble. Off with me!



mhx
Enthusiast / Moderator

Aug 2, 2001, 11:45 PM

Post #8 of 8 (2434 views)
Re: Dinamic Pages [In reply to] Can't Post


In Reply To
... and get ugly html code ...

or get nice html code...

Code
use CGI::Pretty ':html3';

-- Marcus ;-)


Code
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= 
($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives