
Jasmine
Administrator
Jan 15, 2000, 1:06 PM
Post #2 of 2
(4662 views)
|
Re: Navigation inside perl scripts.
[In reply to]
|
Can't Post
|
|
Probably the easiest way to do this is to create a library that contains your links, then to require the library in each program. Putting it in its own library file (within a subroutine is a good idea), requiring the library, and invoking the subroutine after $usrname has been defined should do the trick. Example: code for links.pl <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> ###################### # links.pl # # Contains the links for navigation # between programs to maintaining # username. ##################### # SUB NAVIGATION # # Usage: $whatever = navigation($username) # # Description: This subroutine will take # the username that's passed to it and # return the list of links with the username # incorporated into the links. sub navigation { my $user = shift; my $links = qq~ <a href="program1.cgi?usrname=$user>Program 1</a><BR> <a href="program2.cgi?usrname=$user>Program 2</a><BR> <a href="program3.cgi?usrname=$user>Program 3</a><BR> ~; return $links; } 1; </pre><HR></BLOCKQUOTE> Then, in each of your programs that will require the links, put: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> require "links.pl"; $username = $FORM{'usrname'}; #or however you get this info my $navlinks = navigation($usrname); print qq~ <TABLE><TR><TD> $navlinks </TD></TR></TABLE>~; </pre><HR></BLOCKQUOTE> Hope this helps.
|