Sorry, I'm obviously not making myself clear here.
I don't want to use a Global variable.
I have a program in the form:
use strict;
use File::Find;
sub main;
my @dirlist;
main();
exit;
sub main {
findit();
dostuff($_) for @dirlist;
}
sub findit {
find(\&wanted, shift(@ARGV));
}
sub wanted {
return unless -d $_;
push(@dirlist,$File::Find::name);
}
sub dostuff {
print "$_\n"
}
and I want to do it without the global my @dirlist at the top.
I have dumped about 800 odd lines of someone's code & 60 odd subs from this example so massive rewrites aren't the order of the day but I do need to take out all these bloody global vars because they are making my life a real headache.
I'm not sure I understand why I can't just return the array from &wanted or at the very least declare it in findit and have wanted inherit it but <shrugs>.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.