Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Daft text adventure project - from pmas

by pmas (Hermit)
on May 29, 2001 at 23:25 UTC ( #84048=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Daft text adventure project
in thread Daft text adventure project

1. How to store routines in separate files:
#file shared1.pm: use strict; sub xxx1 ($\%\@@) # define xxx1 with prototype { blah blah; return ...; } # end sub xxx1 use Exporter(); @ISA=qw(Exporter); @EXPORT = qw(xxx1); # exports name xxx1
-----------------
Now, in your main.pl program file, you may call subroutine defined in shared1.pm above:
use strict; use shared1; # 'include' shared code ... # call sub defined in shared1.pm my $result = xxx1($arg1, %arg2, @arg3, $optarg1, $optarg2); ...
---------------------
2. In project this huge, I advise to use not only 'use strict' everywhere, you may want to learn how to do 'prototypes' as well. It will help you to detect (some) errors when wrong numbers or types of parameters are passed to subroutine. While on that, you can also learn to pass hashes as references. Good luck on your long jourmey! PMAS

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://84048]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2020-11-27 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?