Tabindex Coding Tip (Perl)

Hi

This is one for anyone using Perl to generate accessible (X)HTML; those 
using other programming/scripting languages may be able to modify this 
for their own environment.

I spent ages inserting tabindex values into files by hand, until a very, 
very simple system dawned on me:

1) Declare a tabindex global variable at the beginning of the programme:
our $tabindex;  # Use 'our' to declare global scope when using 'strict'

2) Create a subroutine that can increment the variable and return a 
reference to it:

sub tabindex {
	$tabindex++;
	return (\$tabindex);
}

3) Create your tags thus:

print "<a href=\"http://foo.bar.baz\" tabindex=\"${tabindex()}\">";

There are obvious limitations to this, including if you want to break 
from "natural order", but hopefully this will save someone out there a 
lot of time...

Cheers

M

-- 
Matthew Smith            | Business: http://www.kbc.net.au
IT Consultant            | PGP Key:  http://gpg.mss.cx
Kadina, South Australia  | * Tivis Project * Community Connect *

Received on Saturday, 7 December 2002 17:55:25 UTC