Reputation: 2951
Is this an acceptable way to reconfigure without exiting the script?
use XML::Simple;
my $config = "C:/users/config.xml";
my $config = new XML::Simple->XMLin($config_file);
my $volume = $config->{volume};
print "volume 1 $volume\n";
sleep 15;#during this time, change config.xml
my $config = new XML::Simple->XMLin($config_file);
my $volume = $config->{volume};
print "volume 2 $volume\n";
o/p
volume 1 1
volume 2 0
Upvotes: 3
Views: 73
Reputation: 3837
Not the most efficient way, but certainly acceptable. If it's a sizeable configuration file and processing time is relevant you'd want to check the file has been changed before reloading it.
Upvotes: 3