Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Daft text adventure project - from pmas

by pmas (Hermit)
on May 29, 2001 at 23:25 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://84048]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-04-25 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found