Good evening dear list

hello Brandon hello all! 

here i am back agian: with new findings - here new results of the first 
trials.. See more below:

According the above findings regarding the path - i have changed in the parser 
some lines. I found out that these lines were very helpful - since they found 
the files: So i grabbed these two lines


my @files = File::Find::Rule->file()
->name('einzelergebnis*.html')


out of these code snippet (see also further above)

PHP Code:
#!/usr/bin/perl 
use strict; 
use warnings; 
use diagnostics; 
use File::Find::Rule; 
my @files = File::Find::Rule->file() 
->name('einzelergebnis*.html') 
->in('.'); 



i added these two lines of a path-definition the following code: and runned it 
via command line!


PHP Code:
#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;
use File::Find::Rule;
use HTML::TokeParser;

#my $file = 'school.html'

m...@files= File::Find::Rule->file() 
 ->name('einzelergebnis*.html') 
 ->in(*'.'*); 
my $p = HTML::TokeParser->new($file) or die "Can't open: $!";
my %school;
while (my $tag = $p->get_tag('div', '/html')) {
 # first move to the right div that contains the information
 last if $tag->[0] eq '/html';
 next unless exists $tag->[1]{'id'} and $tag->[1]{'id'} eq 'inhalt_large';
 
 $p->get_tag('h1');
 $school{'location'} = $p->get_text('/h1');
 
 while (my $tag = $p->get_tag('div')) {
 last if exists $tag->[1]{'id'} and $tag->[1]{'id'} eq 'fusszeile';
 
 # get the school name from the heading
 next unless exists $tag->[1]{'class'} and $tag->[1]{'class'} eq 
'fm_linkeSpalte';
 $p->get_tag('h2');
 $school{'name'} = $p->get_text('/h2');
 
 # verify format for school type
 $tag = $p->get_tag('span');
 unless (exists $tag->[1]{'class'} and $tag->[1]{'class'} eq 'schulart_text') {
 warn "unexpected format: parsing stopped";
 last;
 }
 $school{'type'} = $p->get_text('/span');
 
 # verify format for address
 $tag = $p->get_tag('p');
 unless (exists $tag->[1]{'class'} and $tag->[1]{'class'} eq 'einzel_text') {
 warn "unexpected format: parsing stopped";
 last;
 }
 $school{'address'} = clean_address($p->get_text('/p'));
 
 # find the description
 $tag = $p->get_tag('p');
 $school{'description'} = $p->get_text('/p');
 }
}

print qq/$school{'name'}n/;
print qq/$school{'location'}n/;
print qq/$school{'type'}n/;

foreach (@{$school{'address'}}) {
 print "$_\n";
}

print qq/nDescription: $school{'description'}n/;

sub clean_address {
 my $text = shift;
 my @lines = split "\n", $text;
 foreach (@lines) {
 s/^s+//;
 s/s+$//;
 }
 return @lines;
} 



results:

# perl perl_script_four.pl

Quote:
Bareword found where operator expected at perl_script_four.pl line 15, near "my 
$p = HTML::TokeParser->new($file) or die "Can't"
(Might be a runaway multi-line '' string starting on line 14) (#1)
(S syntax) The Perl lexer knows whether to expect a term or an operator.
If it sees what it knows to be a term when it was expecting to see an
operator, it gives you this warning. Usually it indicates that an
operator or delimiter was omitted, such as a semicolon.

(Do you need to predeclare my?)
String found where operator expected at perl_script_four.pl line 36, near "warn 
""
(Might be a runaway multi-line "" string starting on line 15) (#1)
(Missing semicolon on previous line?)
Backslash found where operator expected at perl_script_four.pl line 60, near 
"$_\"
(Might be a runaway multi-line "" string starting on line 44) (#1)
(Missing operator before \?)
String found where operator expected at perl_script_four.pl line 67, near "my 
@lines = split ""
(Might be a runaway multi-line "" string starting on line 60) (#1)
(Missing semicolon on previous line?)
String found where operator expected at perl_script_four.pl line 67, at end of
line (#1)
(Missing semicolon on previous line?)

syntax error at perl_script_four.pl line 15, near "my $p = 
HTML::TokeParser->new($file) or die "Can't "
Can't find string terminator '"' anywhere before EOF at perl_script_four.pl 
line 67 (#2)
(F) Probably means you had a syntax error. Common reasons include:

A keyword is misspelled.
A semicolon is missing.
A comma is missing.
An opening or closing parenthesis is missing.
An opening or closing brace is missing.
A closing quote is missing.

Often there will be another error message associated with the syntax
error giving more information. (Sometimes it helps to turn on -w.)
The error message itself often tells you where it was in the line when
it decided to give up. Sometimes the actual error is several tokens
before this, because Perl is good at understanding random input.
Occasionally the line number may be misleading, and once in a blue moon
the only way to figure out what's triggering the error is to call
perl -c repeatedly, chopping away half the program each time to see
if the error went away. Sort of the cybernetic version of S<20
questions>.

Uncaught exception from user code:
syntax error at perl_script_four.pl line 15, near "my $p = 
HTML::TokeParser->new($file) or die "Can't "
Can't find string terminator '"' anywhere before EOF at perl_script_four.pl 
line 67.
at perl_script_four.pl line 67
suse-linux:/usr/perl #



Well now i have to figure out what is wrong!?
___________________________________________________________
WEB.DE DSL Doppel-Flat ab 19,99 &euro;/mtl.! Jetzt auch mit 
gratis Notebook-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to