ckdot has asked for the wisdom of the Perl Monks concerning the following question:

Hello. Maybe should start by saying I have no idea what I'm doing. I have a Palm program that uses a script to translate movie times from a Yahoo website. But, Yahoo changed their website format..

I think I have traced the error to a date string...below is the string in the script that is generating the error
sub AddDate ( $ ) { my ( $datestr ) = @_; trim_whitespace ($datestr); my $DID; if ( !exists ( $hTempDates { $datestr })) { $DID = $nDate ++; $hDates { $DID }{ Date } = $datestr; $hTempDates { $datestr }{ ID } = $DID; } else { $DID = $hTempDates { $datestr }{ ID }; } return $DID; }

The line just above "return $DID;" is the line that is generating the error when I try to run the script.
I think it relates to the following string:(in what I think is a "sub-script" ? - yahoo.pm -specifically geared to translate the yahoo website into the script)
my $datestr; if ( $header =~ /(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(\ +w*)\s(\d\d),\s(\d\d\d\d)/s ) { my $monthstr = $1 . $2; my $day = $3; my $year = $4; my $month=$months{$monthstr}; $datestr = sprintf ( "%04d-%02d-%02d", $year, $month+1, $day ); } my $DID = main::AddDate ( $datestr );

the yahoo website this utilizes is below (from zip code 29681. The following URL is the one that was used when the script was functioning properly.

http://movies.yahoo.com/showtimes/showtimes.html?z=29681&r=sim&m=&t=&a=&dt=0&s=tm&p=0

This URL is the one that is currently used to access the website:
http://movies.yahoo.com/showtimes/showtimes.html?z=29681&date=20040416&nt=10

First (original) URL diplayed only 1 week of dates, second you get to "choose" from up to 30 dates...
I am not sure how complex of a problem this is. My knowledge of PERL is so limited I have no idea where to start. I am willing to put in the work to figure out how to fix this - I just need some direction as to how....
I need to make sure to give credit to J. Robert Ray for writing the original script, but he is no longer supporting it..

Please let me know if I need to post/link to the whole script for a better understanding...and I'll need someone to tell me how. I've looked on the perlmonks help - but can't figure out how to post my whole code files..

Replies are listed 'Best First'.
Re: date problem with movie script
by matija (Priest) on Apr 16, 2004 at 05:38 UTC
    You say "the line is generating an error". What kind of an error?

    Is it a warning about an uninitialized variable?

    Is it an error that terminates the script?

    Is it a logic error (i.e. a bug?) In which case, how sure are you the bug really originates in that line?

      The error is:
      Use of uninitiated value in exists at getdata.pl line 1943
      Use of uninitiated value in hash element at getdata.pl line 1948

      That is on the "first" URL, on all subsequent ones (there are 6 more, for total of 7 days of movietimes) there is the first line "1943" error, plus this:
      Use of uninitiated value in hash element at getdata.pl line 1952

      The script finishes executing, but it does not "parse" (?) the data for download to my PalmPilot.

      I think it is that line because it is what I think is the part of the program that tells it what date to look at/for. Yahoo changed their website format so the dates are different now. (refer to original posting for this logic) Note - I know so little about PERL & programming my logic may be flawed..

      Let me know what other information I need to post if something is unclear
        I'm sorry - either the original page has changed, or I'm missing something, but I don't see the difference in dates between the two pages.

        IMHO your best bet would be to either read perldoc perlre which will teach you to make regular expressions for yourself, or use Date::Manip to translate the date into the form you need. Or both, quite possibly.

Re: date problem with movie script
by theguvnor (Chaplain) on Apr 16, 2004 at 18:17 UTC
      Thanks for the suggestion - I was not sure how to post and/or allow access to the entire set of code. You can go to http://showtimes.jrray.org

      The files I am trying to get working are:

      yahoo.pm and
      getdata.pl

      I think you should be able to run the script even if you don't have a Palm.
        Use of uninitiated value in exists at getdata.pl line 1943

        Usually I get this error when I have use strict; and then the line in question doesn't have a conditional like:

        print $this if ($this); ## if $this has some value...

        {\('v')/}
        `(___)' __________________________
Re: date problem with movie script
by Anonymous Monk on May 07, 2004 at 18:56 UTC
    I'm nowhere near a perl expert, but I had the same problem with yahoo.pm; more important than the date format is the change to the delimiter strings used in the various split calls.

    For example, splitting $theater should use "ygfa" now, splitting $movie should use "/span", and there some additional filters needed on $movieinfostr and $showtimes.

    I do have a version that works for me; the date is still wrong, but at least it downloads movie times. The old dt=1 functionality for looking ahead a day is no longer available, replaced by date=20040416, and I haven't fixed that yet.

    Send mail to pf AT hc.ti.com and I'll send you what I have.