Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2018-10-16 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (83 votes). Check out past polls.

    Notices?