Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Strange problems with CGI script

by PodMaster (Abbot)
on Jan 28, 2003 at 09:29 UTC ( [id://230536]=note: print w/replies, xml ) Need Help??


in reply to Strange problems with CGI script

Don't ask me to explain what the code does.

What is it supposed to do?

What makes a bad question? Before You Post ... How (Not) To Ask A Question How to ask questions the smart way

It's a bad idea to try to parse HTML using regular expressions (especially like that). There are some pure perl html parsers available if you're really in a bind, like YAPE::HTML by japhy, a real perl regex hacker.

Anyway, my own HTML::LinkExtractor seems perfect for what you're trying to do, which I'm guessing is something like:

#!perl #!/usr/bin/perl use CGI qw[:standard]; use HTML::LinkExtractor; use strict; use warnings; print header,start_html; { my $count=0; my $lE = HTML::LinkExtractor->new( sub { my( $lE, $t ) = @_; if( $t->{tag} eq 'a' ) { my ( $outer, $inner ) = $t->{_TEXT} =~ /(\d+)\((\d+)\) +/; return unless $outer and $inner; print a( { -href => $t->{href} }, $count++ ), qq{ [ $outer ][ $inner ]}, br; } } ); $lE->strip(1); $lE->parse(\q[ <a href = "http://polisource.com">12(2345678901234)</a> ]); } print end_html;


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Strange problems with CGI script
by Wassercrats (Initiate) on Jan 28, 2003 at 09:47 UTC
    Extracting the links was the easy part, although maybe I wansn't perfect. The harder part was manipulating them the way I wanted, which seemed like a custom job, so I didn't research the various modules. The REAL problem was having Perl stop without giving me an error. Somehow, other experienced programmers missed it too. I'm not sure how. Sorry about asking incorrectly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://230536]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found