getline parses a single line, but if you want to keep the original lines (so that you can determine the lines that appear in both files), then I don't think it is very useful to you. How about this (untested!)?:
use strict; use warnings; use Text::CSV_XS; my ( $h1, $h2 ) = map get_parsed_lines( $_ ), qw( file_1 file_2 ); my %keep = map +( $_ => $h1->{ $_ } ), grep exists $h2->{ $_ }, keys %$h1; sub get_parsed_lines { my $file = shift; my $csv = Text::CSV_XS->new(); my %hash; open my $in, '<', $file or die "Read failed: $!\n"; while ( <$in> ) { $csv->parse( $_ ) or warn "Bad data: $_\n", next; $hash{ $_ } = [ $csv->fields() ]; } close $in or die "Failed to close $file: $!\n"; return \%hash; }
the lowliest monk
In reply to Re: Question about text::csv_xs
by tlm
in thread Question about text::csv_xs
by Thargor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |