> what about variables used just within the function
Unless there is a good reason for it, all variables inside a function should be declared inside of the function by using 'my'. ...If you can't think of a good reason not to use 'my', then you should use it. > What do you mean 'pass by global variable'? I think he means doing this... my $x = 1234; &foo; sub foo { print $x; } Although this will work you should pass the value to the function like this... my $x = 1234; foo($x); sub foo { my $y = shift; print $y; } As far as why you should use "my" and strict there are lots of answers. Some are that it catches buggy code (especially typos in variable names), it saves time later when you need to maintain your code, the next guy to modify your code won't curse you out, and it's just the "proper" way of doing things. It takes a little bit of time to get used to always using strict, and/or always using warnings, but it is always worth the effort, and I doubt that many will tell you differently. Rob -----Original Message----- From: HENRY,MARK (HP-Roseville,ex1) [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 14, 2002 5:08 PM To: '[EMAIL PROTECTED]' Cc: HENRY,MARK (HP-Roseville,ex1) Subject: Re: 'my' variables Jonathan, Thanks for the reply.. >use strict; >Always, always, declare your variables with my.[1] What do you mean by "function" variables? Ok, I understand you mean use 'my' to declare containers for incoming arg variables - what about variables used just within the function - ought they be 'my' vars as well? Does this apply to the main function/main program body too, or is this overkill? >If you are suggesting "pass by global variable" then dont! It can by very hard to debug these programs. What do you mean 'pass by global variable'? Pass the global var in as the arg and work on the same global variable within the function? Thanks! Mark p.s. what does 'shift' refer to - apart from a list operator? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]