[tpm] Good examples?

Adam Prime adam.prime at utoronto.ca
Fri Nov 8 20:25:57 PST 2013

I have no idea if this is a good example or not, but i played around
with SAX a bit when i was looking at the nextbus api earlier this year. 
This is one of the screwy parser things i built in my experiments.


package AgencyParser;
use strict;

use base qw(XML::SAX::Base);

my $agencies;

sub start_element {
    my ($self, $el) = @_;

    if ($el->{'LocalName'} eq 'agency') {
        my $agency;

        foreach my $att (keys %{$el->{Attributes}}) {
            $agency->{$el->{'Attributes'}->{$att}->{LocalName}} =
        push @$agencies, $agency;

sub end_document {
    $agencies = [];

sub end_document {
    my ($self, $doc) = @_;
    return $agencies;



my $agency_parser = XML::SAX::ParserFactory->parser(
    Handler => AgencyParser->new()

my $agencies =

More information about the toronto-pm mailing list