Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Perl parse text file using hash

by BillKSmith (Monsignor)
on Dec 20, 2022 at 18:46 UTC ( [id://11149001] : note . print w/replies, xml ) Need Help??


in reply to Re^2: Perl parse text file using hash
in thread Perl parse text file using hash

Rolf, That is a cleaver use of the Multi-Dimensional Array Emulation syntax even though that is not exactly what we are doing.

In the spirit of 'not inventing a wheel', perl can also do the input, looping and splitting for us if we use the -n and -a command switches. (perlrun).

#!perl -na use strict; use warnings; our %info; $info{$F[0],$F[1]} = $F[2]; END{ my $name = 'Jack'; my $fruit = 'pineapple'; my $path = $info{$name,$fruit}; print "$name $fruit $path\n"; }

OUTPUT:

>perl 1114899a.pl paths.csv Jack pineapple /path/to/somewhere/b
Bill