On Mon, Dec 10, 2007 at 11:12:22AM -0600, [EMAIL PROTECTED] wrote: > I'm trying to convert over from yrs of not bothering to use `my var;' for > variables in my scripts (All are less than 300 lines) > > It seems to be a big pita for the most part with no real gain. Given > the brief and simple nature of my scripting needs. But that is > probably due to developing a sloppy style. > > I'm not wanting to start a discussion about the value of using `my' > here, just looking for some advice on its use.
I suspect I'll get lynched, but if you are happy with your style and it works for you then feel free to stick with it. If it's more pain than it's worth, then don't do it. However, giving it a good chance, as you seem to be doing, is a sensible decision. Also, remember that "vars" is only one third of "use strict". Even if you don't want that part, you might find value from the other parts. > My usage below is not in line with what is advocated here about using > `my' and I'd like for it to get closer to that goal. > > There is a lot of declaring in main that should be more localized. So > I'm looking for pointers about how to correct it. > > I've declared `my %data;' in main because the uniqifyer code inside > `wanted()' fails if declared inside `wanted()' and a directory path > for each file found gets collected so repeated collection of same path > occurs. How do I get around that? I don't think you do. Sometimes a module's interface is not everything it might be, and you just have to live with that. > I've declared [EMAIL PROTECTED]' in main because I want to use it in > `report()'. But there is more to scoping than subroutine and global scope. Perhaps something like the following might help, by keeping variable to the smallest scope necessary: #!/usr/bin/perl ... { my (%data, @SearchedDir); sub wanted { ... } sub report { ... } } ... -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/