----- Original Message ----- From: "Bob Showalter" <[EMAIL PROTECTED]> To: "'Lysander'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, January 24, 2002 2:48 PM Subject: RE: Trying to use strict
> > -----Original Message----- > > From: Lysander [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, January 24, 2002 3:23 PM > > To: [EMAIL PROTECTED] > > Subject: Trying to use strict > > > > > > Okay, after reading various documents online I have decided > > to try and write my code using -w and strict. > > Excellent! > > > > > So here is the problem. How do I pass Arrays to subs? I > > assume declaring everything main:: would pretty much > > undermine the whole point of strict vars. So... for example > > I have this sub which sends me mail if there is an error. > > > > ...snip a huge bunch of stuff... > > 'use strict' has nothing to do with passing stuff to subs. It is > a compile-time pragma that catches common errors due to misspelled > variable names, use of symbolic refs, etc. > > When you add 'use strict' to an existing script, you need to declare > the variables used, typically by using 'my' (but sometimes by 'use vars' > or 'our'). > > So, if you use an array @headers in your script, you simply need to add the > line > > my @headers; > > to the top of your script. Likewise with other variables like this. > That's all you need to do. > > Now, if you misspell it somewhere in your script as @heders, or use > $headers{0} when you meant $headers[0], you'll get a nice compile-time > error message instead of having to track down why your program isn't > behaving properly. > > HTH I had figured that out on my own. The problem I was trying to convey is that prior to using strict I had to Arrays, @headers and @body. In several subs I access the information in these arrays. Now when I declare these arrays with my they are no longer accessable to my subs. I realize that I could declare them @main::headers and @main::body but thought that since one of the things strict does is help to avoid global variables that I might be better of passing the values to the subs instead of making them global. If this is not correct, then I will just use @main:: If it is, however, then I need some advice on how to get a string and two Arrays passed to a sub. I hope that clears up my question =) Sheridan Saint-Michel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]