|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I've only been programming in perl for a week so forgive me if this question sounds stupid...
Am I correct in thinking that the only reason for passing parameters to submodules and returning values from them is to keep with the "good programming practice"? Because all variables in a program are global right? Theres no way to make them local to a method block is there? (* I not talking about OO programming here). |
|
#2
|
|||
|
|||
|
You can localize variables inside a block using the 'my' command.
Code:
my $number; that variable will exist only within the block that you initialize it in. You can also use the 'local' command to do roughly the same thing, but for more specific situations. using 'my' is generally what you want, unless you know for certain that you should be using 'local' |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > passing parameters |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|