Tue, 23 Dec 2003PHP -> perl HTML::Mason
I'm going to have a go learning HTML::Mason and in the process of doing so will convert this entire site to mason. I'll be posting updates and neat things I learn here, stay tuned...
Comments: 0 (view comments)
perl's CGI module
I have overlooked some of the coolest parts of perl's CGI module for the longest time - I've known it can generate HTML but I've always shrugged it off as thinking it can't do what i want it to, i couldn't have been more wrong.
What I'm specifically referring to is form generation. The rest of the HTML generating methods are useless to me (like the h1() method), but I'll focus on the cool form generating ones.
$poop = "email_address";
$default = "user@somedomain.com"
print 'Email address: <input type="text" name="' . $poop .
'" value="' . $default . '"><br>';
This prints out happy html that looks like this:
Email address:
Now, that print line is pretty damn ugly, but we can easily make it pretty once more by doing: use CGI qw/:standard/; print "Email Address: " . textfield($poop, $default) . "<br>"; And the output is:
Email Address:
Neat? Yeah.. What next? More neatness! You have an array you want to turn into a group of checkboxes...
use CGI qw/:standard/;
@foo = ("check1", "foo", "bar", "baz", "poopie", "hello", "Coke!", "Pepsi?");
@def = ("foo", "bar", "poopie");
print 'Checkbox listing:<br>';
print checkbox_group(-name => "options", -values => \@foo,
-columns => 3, -defaults => \@def);
print '<br>';
What does this look like?
Checkbox listing:
Comments: 0 (view comments)
|
Search this siteNavigationMetadataHome About Resume My Code (SVN)ArticlesARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work EfficiencyProjectsfex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scriptsPresentationsYahoo! Hack Day '06 Unix Essentials Vi/Vim EssentialsTag CloudCalendar
FriendsBarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler ShieldsTechnorati |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||