Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Critique/Test my first module MetaParser

by tachyon (Chancellor)
on Nov 15, 2004 at 02:27 UTC ( #407754=note: print w/replies, xml ) Need Help??


in reply to Critique/Test my first module MetaParser

As previously noted your parsing is broken. If you really want to use REs something like this is *less broken*

use LWP::Simple; use Data::Dumper; my $content = get('http://www.perlmonks.com') or die $!; $content =~ s/\s+/ /g; # condense whitespace (optional) my @meta = $content =~ m/<\s*meta([^>]+)>/gi; for ( @meta ) { m/name\s*=\s*"([^"]+)/i # double quotes || m/name\s*=\s*'([^']+)/i # single quotes || m/name\s*=\s*(\S+)/i # no quotes || m/http-equiv\s*=\s*"([^"]+)/i || m/http-equiv\s*=\s*'([^']+)/i || m/http-equiv\s*=\s*(\S+)/i || next; my $name = $1; m/content\s*=\s*"([^"]+)/i || m/content\s*=\s*'([^']+)/i || m/content\s*=\s*(\S+)/i || next; $meta{$name} = $1; } print Dumper \%meta;

cheers

tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://407754]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2018-07-18 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (392 votes). Check out past polls.

    Notices?