in reply to Re: Re: Perl Modules
in thread Perl Modules

perhaps somebody can explain to me why absolutely NOTHING prints to the screen... even if there are no values defined in the tokens hash, it should still parse the html file and return the contents. even if i use print statements in the module... nothing... I feel there is some very basic logic that i am missing here.

Replies are listed 'Best First'.
Re: Re: Re: Re: Perl Modules
by Belgarion (Chaplain) on Apr 23, 2004 at 21:46 UTC

    Well, for one think you didn't follow the suggestions by kvale. Also, your loadFile function is wrong. Try this instead:

    # this file reads a text file and loads the contents into # an array sub loadFile($) { my $self = shift; my ($filename) = @_; open (FILE, "<$filename") or die("cannot open the file: $filename" +); while (<FILE>) { $body .= $_; } close(FILE); return($body); }

    Update:
    Also, your calls to HTML::pageParser are incorrect. They should read:

    my $myPage = HTML::pageParser->new($sysLoc); $myPage->{tokens}{fName} = "Brandon"; #definite problem here, dunno ho +w to format this $myPage->{tokens}{lName} = "Smith"; #definite problem here, dunno ho +w to format this $data = $myPage->loadAndParse("parseThis.txt");
    See if this makes a difference.