[PHP] porting problem

2001-05-20 Thread Matt Broughton

I'm new to PHP but have found it easier to use than perl...however I'm in
the midst of converting my whole site to php from perl and Ive run into a
bit of a problem.  Everything except one page is database driven, so I
havent had to parse much text or grab info from other sites.  I've got a
movies page written in perl that does both, its very quick and dirty and
shouldnt take long for someone a bit more experienced in php than I am to
port over.  Would anyone be interested in helping?  Please reply directly.

-Matt Broughton


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] porting from perl

2001-05-20 Thread Matt Broughton

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{.*(.*).*}{$1}gism;

my @lines = split(/\n/, $content);

my $act = '';
foreach (@lines) {

next if m{^/);
if (//) {
print "\n";
$act = 'theater';
next;
}
elsif (//) {
$act = 'movie';
next;
}
elsif (//) {
$act = 'info';
next;
}
elsif (/more theaters/i) {
$act = 'done';
last;
}

# Strip font tags
s{}{}gi;
# Strip HR's
s{}{}gi;
# Strip non-breaking spaces
s{( )+}{ }gi;
s{}{}gi;

if ($act eq 'theater') {

# Remove links to Yahoo theater stuff
s{(.*?)}{$1}gi;

# Remove Map It link in favor of a linebreak
s{map it}{}i;

# Small-italicize anything that's not the 
theater's name
s{^(.*)$}{$1} unless m{}i;
}
elsif ($act eq 'movie') {
s{}{http://movies.yahoo.com$1";>}gi;
}

$text .= "$_ \n";
}
}
else {
$text .= 'Movie information is unavailable at this time.';
}

print $text;




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]