W3C home > Mailing lists > Public > w3c-wai-ig@w3.org > October to December 2002

Tabindex Coding Tip (Perl)

From: Matthew Smith <matt@kbc.net.au>
Date: Sun, 08 Dec 2002 09:25:21 +1030
Message-ID: <3DF27C59.5050803@kbc.net.au>
To: w3c-wai-ig@w3.org

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 19 July 2011 18:14:07 GMT