Here is what I am trying to do in a Perl script:
$ data = "";
sub loadXMLConfig ()
{
$ filename = "somexml.xml"
$ data = $ xml-> XMLin ($ filename);
}
sub GetVariable ()
{
($ FriendlyName) = @_;
switch ($ FriendlyName)
{
case "My Friendly Name" {print $ data -> {my_xml_tag_name}}
....
....
....
}
}
The problem is that I only use Perl because I am reading from an XML file, but I need to get these variables with a shell script. So here is what I use:
$ perl -e 'require "scrpt.pl"; loadConfigFile(); GetVariable("My Variable")'
This works exactly as expected, but I need to read the XML file every time I get a variable. Is there a way to "save" $data through shell calls? The idea is that I only read the XML file once. If not, is there an easier way to do this? This is what I cannot change:
- Config file is XML
- Need variables in the shell script
source share