Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a subroutine from another file

Status
Not open for further replies.

butterfly06

Programmer
Jun 7, 2006
7
US
Hi,

I would like to call a subroutine from another file in a perl script.
I read a lot of threads on the website. However I am not able to get it running.

For example, my subroutine called getDescription in the description.pl and my main script named show.pl. They are in the same directory.
I am using perl on WindowXP.

In the show.pl script:

require "description.pl";
&getDescription();

---------------
The subroutine:

sub getDescription{
print "Hallo World\n";
1
}

----------------

I got an error message: Internal Server Error

Could someone please help me?
Thanks

 
you need to take the 1 and put it at the end of the scripts and place a simi-colon after it like this...
Code:
sub getDescription{
    print "Hallo World\n";
}

1;

the 1; goes right at the end of the script, all on it's own not inbetween any curly braces or other subs

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I still get the same error message.
Do I need to setup the perl environment?
 
If you are testing this via the web you need to add a header
Code:
sub getDescription {
    print "content-type: text/html\n\n";
    print "Hallo World\n";
}

1;

M. Brooks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top