use strict; use warnings; use autodie; my $file = \<<'EOF'; Albert apple /path/to/somewhere/a Jack pineapple /path/to/somewhere/b Jack apple /path/to/somewhere/c Dex jackfruit /path/to/somewhere/d EOF open( my $fh, '<', $file); my %info; while (<$fh>) { my @fields = split; my $key = "$fields[0]!$fields[1]"; my $path = $fields[2]; $info{$key} = $path; } close $fh; my $name = 'Jack'; my $fruit = 'pineapple'; my $path = $info{"$name!$fruit"};
In reply to Re: Perl parse text file using hash
by BillKSmith
in thread Perl parse text file using hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |