sub runit {
# first filter out the relevant telinfo:
open TEL, "lynx -dump zoekopnummer.ath.cx/index.php?nummer=$nummer|";
open (LOG, ">$log");
while(<TEL>){
print LOG $_;
}
was part of my first version. I just changed the fetching of the page and used the, "in you own words", bad method you used. Just calling it copy/paste is not entirely fair I think, but hey, I gotta admit, you're a far better coder than me.
>So !!!!!!!!!!!!!!hallo wereld!!!!!!@#$@#$%^#$%^#$%^#"$%#$%#"$%"#$%#$%"#$%123-4567890!!!!!!!!!! is a valid Dutch phone number? >Besides that, it's possible to have a three-digit area number and a 6-digit subscriber number. With 06 number's it's 2-8, even.
Nope, it isn't. And according to testing on my windows machine and my linux machine this tiny utility doesn't think it is either.
As for 06 numbers, they are not listed on this site , so it's pretty useless to check for them, and the same goes for servicenumbers, I guess that's what you're aiming at with the three-digit area number and a 6-digit subscriber number.
You're totally right about the sloppy matches and about the the unnecessary "ignore case" substitution. So here's a rewitten version that fixes (most of) those mistakes and remarks.
Oh, and using LWP::Simple ;)
#!/usr/bin/perl -w
#gettel.pl - poor man's foongrep for dutch telephone numbers
use strict;
use LWP::Simple;
my $nummer;
sub jammer_hoor {
print
"Usage: Specify a dutch telephone number like\ngettel.pl 020-123
+4567\n";
exit;
}
if ( $ARGV[0] ) {
$nummer = $ARGV[0];
}
else {
jammer_hoor();
}
if ( $nummer !~ m/\b\d{3}-\d{7}\b/ ) {
jammer_hoor();
}
#get page
my $url = "http://zoekopnummer.ath.cx/index.php?nummer=$nummer";
my $info = get($url);
#no more newlines!
$info =~ s/\n//g;
#substitute number
$nummer =~ s/-//g;
if ( $info !~ m/Naam:/g ) {
print "\nNo info found on that number\n";
exit;
}
for ($info) {
#filter out all the adds and links
s/$nummer//g;
s/<.*?>//g;
s/\.\.\..*?\.\.\.//g;
s/\{.*?\}//g;
s/\(.*?\)//g;
s/table.*?://gi;
s/1\ item.*?sp\;//gi;
s/2\ item.*?sp\;//gi;
s/\s+/ /g;
s/Telnr: /\n/g;
s/Naam: /\n/g;
s/Adres: /\n/g;
s/Plaats: /\n/g;
s/Postcode: /\n/g;
s/Fax: /\nfax: /g;
}
print $info;
Teabag
Sure there's more than one way, but one just needs one anyway - Teabag
|