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


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 {
	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...



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

This archive was generated by hypermail 2.3.1 : Tuesday, 13 October 2015 16:21:21 UTC