#!/usr/bin/perl use strict; use warnings; use Text::CSV_XS; use Data::Dumper; my $param = { binary => 1, auto_diag => 1, sep_char => ' ', eol => $/, }; my %hash; my $csv = Text::CSV_XS->new ( $param ); while ( my $row = $csv->getline( *DATA ) ) { print "@$row[0,1]\n"; # or whatever. $hash{$row->[0]} = $row->[1]; # read into a hash. } print Dumper \%hash; __END__ b c a a c d d e b