Hello Monks,
I'm attempting to use File::Find to generate formatted output of a directory structure, and it appears that scoping issues are killing me. I'm unclear on what to do with this.
What I'm doing is something like this (rather snipped up to limit this to the relevent parts):
sub a_moduser {
our $user = shift;
our $html;
[...]
$html = '<form action="' . $$config{selfpath} . 'method="post
+">';
find(\&wanted, $$config{base_dir});
[...]
}
sub wanted {
[...]
$html .= '<td><input type="radio" name="base_dir" value="' . $_ .
+'"></td>';
[...]
}
So,
$user and
$html are both apparently out of scope:
Variable "$html" is not imported at fileman.cgi line 707.
Variable "$html" is not imported at fileman.cgi line 708.
Global symbol "$html" requires explicit package name at fileman.cgi li
+ne 707.
Global symbol "$html" requires explicit package name at fileman.cgi li
+ne 708.
I tried sticking the variables and the find call in a BEGIN block, which shut the error messages up, but caused all sorts of grief with calling other subroutines. I'm a little lost in terms of what to do from here. Any kindly monks with suggestions? Thanks much.
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.