I have the following code:
my @logs = split(",",$opts->{"logs"});
$opt_href->{"logs"} = \@logs;
It basically splits the $opts->{"logs"}
by comma and keeps the array ref. Later I need to check if string exists in the $opt_href->{"logs"}
array. Looking at this topic, I see that it's recommended to keep a hash, instead of array. I could just do:
my %logs;
for each my $log (split(",",$opts->{"logs"})) {
$logs{$log} = 1;
}
$opt_href->{"logs"} = \%logs;
Is there a better way to do this? Maybe a one/two liners?