On Sat, Oct 22, 2011 at 7:13 PM, Brian Fraser <frase...@gmail.com> wrote:
> I say this without a bit of sarcasm: Feel blessed in your ignorance of
> formats. The declarations on top are unfortunately needed (If it helps,
> think of formats using lexical variables as closures).
> But you shouldn't be using formats. So yeah.

Well that's embarrassing. :P Well, after reading perldoc perlform
it seems the problem is that the variables need to be visible
where the format is declared. I can think of a couple of
alternatives:

You could move the form declarations into the while loop so that
the lexicals are visible to it. Alternatively, you could move
them into a sub:

sub disk_free_form
{
    my ($filesys, $mbytes, $used,
        $avail, $capacity, $mount) = @_;

    format STDOUT_TOP =
...etc...
.

    format =
...etc...
.

    write;
}

I don't know what other people would prefer, and I'm not sure it
matters since forms seem to be considered bad practice most of
the time.

As a last ditch attempt to salvage my pride, it still seems
unnecessary to initialize the variables, even if you do chose to
lexically declare them at the file level. :P


-- 
Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to