in reply to Re: Parsing COD text help
in thread Parsing COD text help
#!/usr/bin/perl use strict; use warnings; use HTML::TokeParser::Simple; my $file = 'APMA.txt'; my $stream = HTML::TokeParser::Simple->new( $file ); while( my $t = $stream->get_token ) { if( $t->is_start_tag( 'a' ) and $t->return_attr( 'href' ) =~ m/course_nbr/ ) { print "Class: ", $stream->get_text( '/a' ), " "; } elsif( $t->is_start_tag( 'span' ) ) { my $class = $t->return_attr( 'class' ); my $title = $t->return_attr( 'title' ); if( defined $title and not defined $class ) { print "Title = $title: ", $stream->get_text( '/span' ), "\ +n", } elsif( defined $class and $class eq 'title' ) { print $stream->get_text( '/span' ), "\n"; } } }
Makeshifts last the longest.
|
|---|