local variables and global variables

K

king

Hi,
How and what should be used to define a local variable and a global
variable as well.

and if i have used a sub-routine in a script and i want to use that
sub-routine in another script,
how can i do that.

regards
 
J

Jürgen Exner

king said:
How and what should be used to define a local variable and a global
variable as well.

In Perl variables are defined by assigments. You simply do
$var = said:
and if i have used a sub-routine in a script and i want to use that
sub-routine in another script,
how can i do that.

You define the subroutine in a module and then import that module in both
scripts.

jue
 
T

Tad McClellan

king said:
How and what should be used to define a local variable and a global
variable as well.


A local() variable *is* a global variable in Perl.

See:

"Coping with Scoping":

http://perl.plover.com/FAQs/Namespaces.html

and if i have used a sub-routine in a script and i want to use that
sub-routine in another script,
how can i do that.


By using a "module":

perldoc -q module

What modules and extensions are available for Perl? What is CPAN?
What does CPAN/src/... mean?

How do I find which modules are installed on my system?

How do I create a module?

How do I install a module from CPAN?

How do I keep my own module/library directory?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,233
Latest member
AlyssaCrai

Latest Threads

Top