Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

mojotoad's scratchpad

by mojotoad (Monsignor)
on Jun 01, 2004 at 13:14 UTC ( [id://358028]=scratchpad: print w/replies, xml ) Need Help??

use strict; use warnings; use Path::Class; my $rootdir = ... # however it happens my $relative_path = file($0)->relative($root_dir); # btw, this does the same if all you want is # the script name: use FindBin; my $name = $FindBin::Script; # there's also $FindBin::Dir, ::RealDir and ::RealScript, # the last two are only relevant for resolving soft links. # Here's Yet Another Way, using Path::Class again: my $script = file(__FILE__)->basename; # If you want to be thorough... $script = file(__FILE__)->absolute; $dir = $script->dir; $script = $script->basename;

A HTML::ElementTable example of chessboard generation...

use strict; use warnings; use HTML::ElementTable; my @back_row = qw(rook knight marshal bishop cardinal queen king cardinal bishop marshal knight rook); my @middle_row = qw(pawn squire squire novice priest princess prince priest novice squire squire pawn); my @front_row = (undef, ('pawn') x 10, undef); my $t = HTML::ElementTable->new(maxrow => 11, maxcol => 11); for my $c (0 .. $#back_row) { $t->cell($_, $c)->push_content($back_row[$c]) for (0, 11); } for my $c (0 .. $#middle_row) { $t->cell($_, $c)->push_content($middle_row[$c]) for (1, 10); } for my $c (0 .. $#front_row) { next unless $front_row[$c]; $t->cell($_, $c)->push_content($front_row[$c]) for (2, 9); } for my $r (0 .. $t->maxrow) { for my $c (0 .. $t->maxcol) { $t->cell($r, $c)->attr(class => $r % 2 ^ $c % 2 ? 'odd' : 'even'); } } print $t->as_HTML;
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-28 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found