#!perl use strict; use Text::CSV; my @ar; @ar = column_segregation('test.csv',0); print "@ar\n"; @ar = column_segregation('test.csv',3); print "@ar\n"; sub column_segregation { my ($file,$col) = @_; my @array_A2 = (); open my $io,'<',$file or die "$!"; my $csv = Text::CSV->new ({ binary => 1 }); while (my $row = $csv->getline($io)) { push @array_A2, $row->[$col]; } close $io; return (@array_A2); } __DATA__ 1,2,3,4,5 a,b,c,d,e 6,7,8,9,0 x,z,y,q.w