#!/usr/bin/perl use strict; use warnings; use diagnostics; use Text::CSV_XS; my $file = 'xt_customers_addresses.csv'; #csv file name my @rows; # array that will store csv values my $csv = Text::CSV_XS->new ({ binary => 1 }) or die "Cannot use CSV: ".Text::CSV->error_diag (); #open file open my $FH, "<:encoding(ISO-8859-15)", "$file" or die "$file: $!"; #skip first n (10 in this case) lines <$FH> for 1 .. 10; #read file in while loop # my $i = 1; while (my $row = $csv->getline ($FH) ) { # if ($i > 1) {push @rows, $row;} # $i++; } $csv->eof or $csv->error_diag (); #close file close $FH; #print contents of @rows array for my $print_rows (@rows) { print "@$print_rows\n"; } # Working with file2 my $file = 'xt_customers_addresses.csv'; #csv file name my @rows; # array that will store csv values my $csv = Text::CSV_XS->new ({ binary => 1 }) or die "Cannot use CSV: ".Text::CSV->error_diag (); my $file2 = 'xt_customers_addresses.txt'; #csv file name my @rows2; # array that will store csv values my $csv2 = Text::CSV_XS->new ({ binary => 1 }) or die "Cannot use CSV: ".Text::CSV->error_diag (); #open file open my $FH2, "<:encoding(ISO-8859-15)", "$file2" or die "$file2: $!"; #skip first n (10 in this case) lines <$FH2> for 1 .. 10; #read file in while loop # my $i = 1; while (my $row2 = $csv2->getline ($FH2) ) { # if ($i > 1) {push @rows2, $row2;} # $i++; } $csv2->eof or $csv2->error_diag (); #close file close $FH2; #print contents of @rows array for my $print_rows2 (@rows2) { print "@$print_rows2\n"; }