in reply to XML::Simple private members
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Simple private members
by Solostian (Beadle) on Sep 14, 2005 at 17:14 UTC | |
|
Re^2: XML::Simple private members
by Tanktalus (Canon) on Sep 14, 2005 at 20:40 UTC |