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.