in reply to Re: Logic Issues with conditionals
in thread Logic Issues with conditionals

thanks for the input Fishmonger! I decided this will be the way to go. I am just having one issue as I am not very familar with hashes at all. Been doing Perl things for quite a while, but hashes or key-value pairs never crossed my mind as a hash of arrays.

that said, I figured out how to get the access part or key out of the hash, but I need to now address the elements of the arrays. For example: If I pull the keys into an array, then I can address them. Maybe there is a more direct way, and that would be nice too. But I also need to figure out how to get say element 0 from the dev array. Help is appreciated!

my %files = ( dev => [qw(testd.txt testd1.txt testd2.txt testd3.txt)], prod => [qw(testp.txt testp1.txt testp2.txt testp3.txt)], report => [qw(testr.txt testr1.txt testr2.txt testr3.txt)], qptool => [qw(testq.txt testq1.txt testq2.txt testq3.txt)], ); @flags = keys %files;

This gets the keys from the hash.

Replies are listed 'Best First'.
Re^3: Logic Issues with conditionals
by fishmonger (Chaplain) on Mar 28, 2015 at 13:20 UTC

    There are multiple ways to access the array elements. The most direct would be:

    my %files = ( dev => [qw(dev_file1 dev_file2 dev_file3 dev_file4)], prod => [qw(prod_file1 prod_file2 prod_file3 prod_file4)], report => [qw(report_file1 report_file2 report_file3 report_file4) +], ); print $files{dev}[0];

    or you could do this

    my @dev = @{ $files{dev} }; print $dev[0];