#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $csv_file = 'test.csv'; # binary => 1 : makes Text::CSV work on multi-lined fields my $csv = Text::CSV->new( { binary => 1 } ); #open my $fh, '<', $csv_file or die "$csv_file: $!\n"; # *DATA; instead of opening a separate file; using the data section at the end of file my $fh = *DATA; # read rows and store them in an array reference while ( my $ref = $csv->getline( $fh ) ) { # dereference the reference and simply print the elements print "@$ref\n"; } #close $fh or die "$csv_file: close failed: $!\n"; __DATA__ "column1","column2","column3" "single1","single2","single3" "single4","multiA multiB",single5