bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:
I am away from that development server but the error was something like unable to load method in IO::Handle.#!/usr/bin/perl use Text::CSV_XS; use IO::File; my $argcount = 0; my $infile = ""; my $arg; my %email; my $em; while (@ARGV) { $arg = shift @ARGV; if ($argcount eq 0) { $argcount++; $infile = $arg; print "Processing: $infile\n"; } } my @rows; my $lineterm = "\r\n"; my $csv = Text::CSV_XS->new ( { eol => $lineterm, binary => 1 } ) # s +hould set binary attribute. or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, "<:encoding(utf8)", $infile or die "$infile: $!"; while ( my $row = $csv->getline( $fh ) ) { # $row->[2] =~ m/pattern/ or next; # 3rd field should match $em = lc($row->[22]); if ($em eq "0") { #print "BAD: ".join(":",@$row)."\n"; } #print "Email: $em\n"; $email{$em}++; if ($email{$em} eq 1) { #print "New email: $em\n"; $row->[22] = $em; } elsif ($email{$em} > 1) { $row->[22] = ""; } push @rows, $row; } $csv->eof or $csv->error_diag(); close $fh; open $fh, ">:encoding(utf8)", "out2.csv" or die "out2.csv: $!"; foreach $row (@rows) { my @columns = $csv->fields($row); my $status = $csv->combine($row) or warn($csv->error_input()); my $outstr = $csv->string(); print $fh "$outstr\n"; } close $fh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: No errors in debugger?
by Old_Gray_Bear (Bishop) on Feb 07, 2011 at 21:52 UTC | |
|
Re: No errors in debugger?
by ikegami (Patriarch) on Feb 07, 2011 at 21:24 UTC | |
|
Re: No errors in debugger?
by ikegami (Patriarch) on Feb 07, 2011 at 22:35 UTC |