RE: RE: I use CGI.pm for
by BBQ (Curate) on Jun 08, 2000 at 01:16 UTC
|
Ok, you're crazy. :)
I guess I'm worse cause I still use the "cgi-lib.pl compatility mode" with ReadParse(*in); Now is that lame or what?
#!/home/bbq/bin/perl
# Trust no1!
| [reply] |
RE: RE: I use CGI.pm for
by merlyn (Sage) on Jun 08, 2000 at 04:51 UTC
|
Thus saith royalanjr:
Call me crazy, but I generally do not let CGI.pm do my HTML. I prefer to write that out myself. Being new, I know I have not explored all its possibilies yet though. I do use it to pass my parameters around.
Once you discover the sticky fields technology of web form generation, you'll never go back. CGI.pm rules!
-- Randal L. Schwartz, Perl hacker | [reply] |
|
Not to mention, with some creative map use, you can create dynamic tables and such pretty easy, while not breaking the stylish print 'some','things','in','a','row'; :-)
use CGI;
my $cgi = CGI->new;
print $cgi->header,
$cgi->start_html('Times Tables'),
$cgi->table( { -border => 1 },
( map {
my $r = $_;
$cgi->Tr( ( map {
$cgi->td( $_ * $r ),
} 1 .. 50 ) ),
} 1..50 ) ),
$cgi->end_html;
And for the obfuscated lovers in all of us (some people would call the above obfuscated.. slackers:-)
use CGI;my$cgi=CGI->new;print##
$cgi->header=>$cgi->start_html#
('Times Tables')=>$cgi->table(#
{-border=>1}=>(map{my$r=$_;$cgi
->Tr((map{$cgi->td($_*$r)}1..50
))=>}1..50))=>$cgi->end_html;##
--
Casey
| [reply] |
|
| [reply] |
|
I agree. Sometimes the stickiness make a script to behave strange, especially if you have a muliple page form generation / evaluation script with hidden fields.
There is a good idea to try the 'override' flag on hidden fields if such a script behaves strange.
/Wonko
| [reply] |
|
Sticky Fields?!?
*pulling at my hair in despair, dropping to my knees*
So much to learn!!!
Roy Alan
"I quit; I concede. Tanj on your silly game!" -- Louis Wu
| [reply] |
|
Sticky fields is a CGI.pm facility which is useful when you have a CGI script which returns multiple forms; The script automatically fills in the old formfield data (i.e. the data that has already been posted)
This is wery useful if you want to keep track of the information the user has already entered in hidden fields, or if you have to resend a form because the user did something wrong
/wonko
| [reply] |
RE: RE: I use CGI.pm for
by flyfishin (Monk) on Jun 08, 2000 at 00:49 UTC
|
Try it you'll like it. I certainly do. It takes a little
bit to get used to but the shortcuts for creating multiple
table rows and table data are invaluable. I certainly don't
know all it can do but the little that I do know sure
seems to go a long ways. It is also easy to switch from using
CGI.pm notation for HTML to simple here documents, if I
want to write out HTML by hand. | [reply] |
|
Personally, I use a mix of it, pending on what i shall do and who i am writing it for. Sometimes I find it easier to use the HTML tags rather than the shortcuts, especially when i make complicated tables. And there's always the option of a external HTML file and use regexps to insert variables:
open(HTML, "<a_file.html") or die "cant open HTML file: $!\n";
while($row = <HTML>) {
$row =~ s/---(.*?)---/eval $1/eg;
print $row;
}
close HTML;
Which will look for ---$variablename--- in the HTML code and replace it with the variable (as if you didnt know ; ))
I also use HTML comment flags to insert more complicated structures. I've written a rather simple Web-based discussion forum using this technique, which allows the administrator of the site to change the design without knowing any Perl at all. | [reply] [d/l] |
|
| [reply] |