9 Einträge, 1 Seite |
1
2
3
4
5
6
7
<a href='anzeig.pl?lnr=2689&art=stadt&nr=5048'><img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Un-Rockbar
Besitzer: Ice_King
Punkte: 144
Bündnis: FuckingGrandpas'></a><a href='anzeig.pl?lnr=2689&art=stadt&nr=5049'><img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Ulgarth
Besitzer: Core
Punkte: 1202
Bündnis: DDH'></a>
1
2
3
4
5
6
foreach( @save ){
if( $_ =~ m|<img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Un-Rockbar Besitzer: Ice_King Punkte: 144 Bündnis: FuckingGrandpas'></a><a href='anzeig.pl?lnr=2689&art=stadt&nr=5049'><img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Ulgarth Besitzer: Core Punkte: 1202 Bündnis: DDH'></a>| ){
print "$_\n";
last;
}
}
1
2
3
4
5
6
7
8
9
10
unless (open (FILE, $filename)) {
# errorhandling
}
else {
local $/ = "\n\n";
while (<FILE>) { # $_ enthaelt nun einen Block
} # while
close (FILE);
} # else
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
my $recordSeparator = "\nName:\s+";
unless (open (FILE, $filename)) {
# errorhandling
}
else {
local $/ = $recordSeparator;
while (<FILE>) {
chomp($_); # entfernt $recordSeparator am Ende
s/^\Q$recordSeparator\E//; # entfernt beim ersten Datensatz $recordSeparator
my ($name, @rest) = split(/\n/, $_);
my %item = (Name => $name);
foreach my $line (@rest) {
my ($key, $value) = split(/\:\s+/, $line, 2); # an : aufsplitten
$item{$key} = $value;
} # foreach
# mach was mit %item
} # while
close (FILE);
} # else
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
use warnings;
use strict;
use HTML::Parser;
# Hier wird jedes Start-Tag ausgewertet
sub parse_start {
return unless $_[0] eq 'img'; # nur IMG-Tags
return unless exists $_[1]->{alt}; # alt-Attribute vorhanden?
my $alttext = $_[1]->{alt};
# mach was mit $alttext
print ">>>\n$alttext\n<<<\n";
}
# Parser definieren
my $p = HTML::Parser->new ( api_version => 3,
start_h => [ # Handler fuer Start-Tags
\&parse_start, 'tag, attr' # Uebergib Tag und Attribute
],
);
# Start des Parsers, hier mit Daten aus dem _ _DATA_ _ Anhang
$p->parse_file(*DATA);
_ _DATA_ _
<a href='anzeig.pl?lnr=2689&art=stadt&nr=5048'><img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Un-Rockbar
Besitzer: Ice_King
Punkte: 144
Bündnis: FuckingGrandpas'></a><a href='anzeig.pl?lnr=2689&art=stadt&nr=5049'><img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Ulgarth
Besitzer: Core
Punkte: 1202
Bündnis: DDH'></a>
1
2
3
4
5
6
7
8
9
10
sub parse_start {
return unless $_[0] eq 'img'; # nur IMG-Tags
#return unless exists $_[1]->{alt}; # alt-Attribute vorhanden?
return unless exists $_[1]->{src}; #meins
return unless $_[1]->{src} =~ /k1j|k0j/;
my $alttext = $_[1]->{alt};
my $src = $_[1]->{src};
# mach was mit $alttext
print "\n$alttext $src\n";
}
1
2
<p class='mitte'>Mittlere Koordinate:<input type="text" name="k1" value="52" maxlength="3" size="3">.<input type="text" name="k2" value="48" maxlength="3" size="3">
<input type="submit" value="Go" name="go"></p>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!c:/usr/bin/perl -w
# ---------------------------------------------------
# KartenScript für SchlachtPlatz 2
# ---------------------------------------------------
# MODULE
# ---------------------------------------------------
use strict;
use warnings;
use diagnostics;
use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
$CGI::POST_MAX=1024 * 100; # max 100K posts
$CGI::DISABLE_UPLOADS = 1; # no uploads
use Data::Dumper;
use HTML::Parser;
use vars;
# ---------------------------------------------------
# KONSTANTEN
# ---------------------------------------------------
use constant UNIX => 0; # Unix y/n
# ---------------------------------------------------
# VARIABLEN
# ---------------------------------------------------
# --- CGI
$| = 1;
my $cgi = CGI->new();
my $query = $cgi->Vars; #extract parameters
# ---------------------------------------------------
# LOGIK
# ---------------------------------------------------
print \print_koords(*DATA)->{1};
#print print_map(*DATA);
# ---------------------------------------------------
# SUBS
# ---------------------------------------------------
sub print_koords {
my $p = HTML::Parser->new ( api_version => 3,
start_h => [ # Handler fuer Start-Tags
\&parse_start, 'tag, attr', # Uebergib Tag und Attribute
],
);
return $p->parse_file(*DATA);
} #print_koords
sub print_map {
my $p_i = HTML::Parser->new ( api_version => 3,
start_h => [ # Handler fuer Start-Tags
\&parse_start_i, 'tag, attr' # Uebergib Tag und Attribute
],
);
return $p_i->parse_file(*DATA);
} #print_map
sub parse_start {
return unless $_[0] eq 'img'; # nur IMG-Tags
#return unless exists $_[1]->{alt}; # alt-Attribute vorhanden?
return unless exists $_[1]->{src}; #meins
return unless $_[1]->{src} =~ /k1j|k0j/;
my $alttext = $_[1]->{alt};
my $src = $_[1]->{src};
# mach was mit $alttext
#print "\n$alttext $src\n";
}
sub parse_start_i {
return unless $_[0] eq 'input'; # nur IMG-Tags
return unless exists $_[1]->{name}; # name-Attribute vorhanden?
return unless $_[1]->{name} =~ /k1|k2/;
my $koN = $_[1]->{name};
my $ko = $_[1]->{value};
# mach was mit $alttext
#print "\n$koN = $ko\n";
}
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
...~100 Zeilen gekürzt...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
use warnings;
use strict;
use HTML::Parser;
my (@Staedte, @Koord1, @Koord2); # globale Variablen fuer Parser-Ergebnisse
sub parse_start {
if ($_[0] eq 'img') {
return unless exists $_[1]->{alt}; # alt-Attribute vorhanden?
push @Staedte, $_[1]->{alt};
} elsif ($_[0] eq 'input') {
if ($_[1]->{name} eq 'k1') {
push @Koord1, $_[1]->{value};
} elsif ($_[1]->{name} eq 'k2') {
push @Koord2, $_[1]->{value};
}
}
}
my $p = HTML::Parser->new ( api_version => 3,
start_h => [ # Handler fuer Start-Tags
\&parse_start,
'tag, attr', # Uebergib Tag und Attribute
],
);
$p->report_tags (qw(img input)); # nur diese Tags beachten
$p->parse_file(*DATA);
# Ausgabe der Ergebnisse
for (0..$#Staedte) {
print "$Staedte[$_]\n===> ($Koord1[$_], $Koord2[$_])\n";
}
_ _DATA_ _
<a href='anzeig.pl?lnr=2689&art=stadt&nr=5048'><img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Un-Rockbar
Besitzer: Ice_King
Punkte: 144
Bündnis: FuckingGrandpas'></a><a href='anzeig.pl?lnr=2689&art=stadt&nr=5049'><img border="0" src="http://free.pages.at/Praios/bilder//karte/k1j.jpg" width="118" height="118" alt='Name: Ulgarth
Besitzer: Core
Punkte: 1202
Bündnis: DDH'></a>
<!-- kommen die einfach hier hinter??? -->
<p class='mitte'>Mittlere Koordinate:<input type="text" name="k1" value="52" maxlength="3" size="3">.<input type="text" name="k2" value="48" maxlength="3" size="3">
<input type="submit" value="Go" name="go"></p>
<p class='mitte'>Mittlere Koordinate:<input type="text" name="k1" value="42" maxlength="3" size="3">.<input type="text" name="k2" value="24" maxlength="3" size="3">
<input type="submit" value="Go" name="go"></p>
9 Einträge, 1 Seite |