>I should have used LWP::Simple and so should you :)

>This is copy/paste-programming, I think. I used LWP::UA
>because some earlier version did some extra work, but I guess you
>just copied my code. My bad code.

Well, the script I wrote before this one used lynx to dump the file. I copied your use of modules to make it more platform-independant.

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

In reply to Re: Re: Poor man's Foongrep for dutch telephonenumbers by teabag
in thread Poor man's Foongrep for dutch telephonenumbers by teabag

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.