use strict; use warnings; #use Data::Dumper; my ($content); { open my $fh,'<','work.conf' or die $!; local $/; $content = <$fh>; } my $config = eval $content; #print Dumper(\$config); print 'Licences: ' . join ',', @{$config->{licence}};
Update: to look at the first and second specifically, try the following.
printf "First licence: %s\n", ${$config->{licence}}[0]; printf "Second licence: %s\n", ${$config->{licence}}[1];
Updated again: if the contents of the licence tag could be either a single value or a list of values, you will need to use the ref command to tell the difference.
use File::Spec::Functions qw/catfile/; ... if (ref($config->{licence}) eq 'ARRAY') { foreach my $lfile (@{$config->{licence}}) { print catfile($::folder,$lfile) } } else { print catfile($::folder,$config->{licence}) }
In reply to Re^2: Recover a path from a config file
by GotToBTru
in thread Recover a path from a config file
by Chaoui05
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |