[ale] perl question

fletch at phydeaux.org fletch at phydeaux.org
Tue Jan 4 14:54:34 EST 2011


> Hi,
>
> I'm doing some perl development and have a function that always reports
> use of
> uninitalized value though I know the values are uninitialized because the
> function would fail if either of them were.  Here's the function, below,
> can
> anyone suggest why this reports uninitialized value?
>

Run through using the debugger (perl -d foo; see "perldoc perldebug" for
more docs) or sprinkle in some prints and verify they contain what you
think they do.

> sub SaveXFer( $$ )
> {
> 	my( $XFer, $ToFile ) = @_;
> 	XMLout( $XFer, AttrIndent => 1, NumericEscape => 2, OutPutFile => $ToFile
> );
> }
>

Two things:

*) presuming this is XML::Simple it wants "OutputFile" not "OutPutFile"
and that's probably what's confuzzling something and producing the
uninitialized gripe

*) 99.7% of the time you don't really want to be using prototypes on subs
in Perl.  They're not what's usually thought of as prototypes, more hints
for the parser to emulate calling conventions of builtins (the canonical
example usually being "sub mypush (\@;@)" I think).


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org|  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U





More information about the Ale mailing list