Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 15th, 2001, 03:08 AM
fighter fighter is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: South Africa
Posts: 0 fighter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

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).

Reply With Quote
  #2  
Old April 16th, 2001, 01:50 PM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
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'

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > passing parameters


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway