porting from perl

From: Date: Mon, 21 May 2001 04:31:35 +0000
Subject: porting from perl
Groups: php.general 
Request: Send a blank email to php-general+get-53668@lists.php.net to get a copy of this message
I'm having some difficulty porting this code from perl to php...can anyone give me a hand? -Matt Broughton #!/usr/bin/perl # Quick and dirty Yahoo movie showtimes grabber use LWP::Simple; my $content = get("http://movies.yahoo.com/showtimes/showtimes.html?z=florence%2C+sc&r=sim "); my $text = ''; if ($content) { $content =~ s{.*<!-- movies module -->(.*)<!-- /movies module -->.*}{$1}gism; my @lines = split(/\n/, $content); my $act = ''; foreach (@lines) { next if m{^</{0,1}(table|tr|td)}; next unless ($act || /<!-- theater -->/); if (/<!-- theater -->/) { print "\n"; $act = 'theater'; next; } elsif (/<!-- .*? movie -->/) { $act = 'movie'; next; } elsif (/<!-- show info -->/) { $act = 'info'; next; } elsif (/more theaters/i) { $act = 'done'; last; } # Strip font tags s{</{0,1}font.*?>}{}gi; # Strip HR's s{<hr>}{}gi; # Strip non-breaking spaces s{(&nbsp;)+}{&nbsp;}gi; s{<p>}{<BR>}gi; if ($act eq 'theater') { # Remove links to Yahoo theater stuff s{<a.*?>(.*?)</a>}{$1}gi; # Remove Map It link in favor of a linebreak s{map it}{<BR>}i; # Small-italicize anything that's not the theater's name s{^(.*)$}{<SMALL><I>$1</I></SMALL>} unless m{<B>}i; } elsif ($act eq 'movie') { s{<a href="(.*?)">}{<a href="http://movies.yahoo.com$1">}gi; } $text .= "$_ \n"; } } else { $text .= '<P>Movie information is unavailable at this time.'; } print $text;

« previous php.general (#53668) next »