
soren at tauberlassen
Apr 19, 2004, 12:59 PM
Post #1 of 2
(1559 views)
Permalink
|
Hi, Below I have listet relevant code of two perl files I'm working on. The problem is that "sub loadFileText" in files.pl, cannot be seen from the file menus.pl, but "sub load_file" can. For some reason, which I can't seem to find, the code generates the error "Undefined subroutine". Why? files.pl: ---------- #!perl.exe use fcntl; # File Control sub load_file { my ($filename) = @_; my @lines; sysopen(FH, $filename, O_RDONLY) # Opens the file or die "Cannot open $filename"; @lines = <FH>; # Reads the entire filecontent into an array of lines close(FH); # Close the opened file return @lines; } sub loadFileText { my $filename = $_[0]; my $text = ""; my @lines = load_file($filename); for(my $i=0; $i<scalar(@lines); $i++) { $text .= $lines[$i]; } return $text; } 1; menus.pl: -------------- #!perl.exe use XML::Parser::Lite; # XML Support require "../../cgi-bin/soren/files.pl"; sub showMenu { # Parameters: my $sSource = $_[0]; my $sID = $_[1]; $sLanguageID = $_[2]; my $xmlDoc = loadFileText($sSource); # <=== loadFileText is undefined ?????? my $sMenu .= createMenu($xmlDoc, $sID); print $sMenu; } 1; /Søren
|