This may be just as objectionable as accessing a private variable, but thought I would throw it out there.
Add the filename as a private part of the XML:
#!/usr/bin/perl use strict; use warnings; use XML::Simple; &main(@ARGV); sub main { my $filename = shift; my $xml = XMLin($filename); $xml->{__SUPER_SECRET_FILENAME_PARAMETER__} = $filename; &printName($xml); } sub printName { my $xml = shift; print $xml->{__SUPER_SECRET_FILENAME_PARAMETER__}; }
Also, I don't think that it is wise to use an exit at the end of a script. I believe that it is better to just return.
UPDATE
Further, the return of XMLin isn't a XML::Simple instance. It's just a hash. So if the item you're looking for isn't in the hash, then it isn't available. There isn't any private data.
Hazah! I'm Employed!
In reply to Re: XML::Simple private members
by osunderdog
in thread XML::Simple private members
by Solostian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |