[TriLUG] Perl CSV

Greg Brown gwbrown1 at gmail.com
Sat Nov 16 18:28:50 EST 2013


Interesting.  What benefits do you find using the Perl Text::CSV module.  I
work with .csv files literally all the time (no joke) but I've stuck with
the tried and true method of the following:

my $infile=somecsvfile.csv
my $line;
my @line;

open(INFILE,$infile) || die "can't open $infile: $!\n";

foreach $line (<INFILE>) {

     chomp($line);
     $line =~ s/\s+/ /g; # get rid of extra spaces
     @line = split(/\,/,$line); # split the line at the commas

     # send hostname and IP address to the subscript and ssh to device






}



On Thu, Nov 14, 2013 at 2:46 PM, Brian McCullough <bdmc at buadh-brath.com>wrote:

> On Thu, Nov 14, 2013 at 02:21:37PM -0500, Brian McCullough wrote:
> > I am sure that somebody here has some experience with the Perl Text::CSV
> > mondule.
>
> Call off the dogs, thanks.
>
>
> > I am trying to use it again, but every row, after $csv->parse, is
> > reporting that there is only one element in the array.
> >
> >       $status = $csv->parse( $row ) ;
> >       @cols = $csv->fields ;
> >       $col_cnt = @cols ;
>
> I found that I was much more successful removing the above, and
> replacing it with:
>
>  @cols = @$row ;
>  $col_cnt = @cols ;
>
>
> Go figure, as they say.
>
>
> --
> This message was sent to: Greg Brown <gwbrown1 at gmail.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that
> address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web  :
> http://www.trilug.org/mailman/options/trilug/gwbrown1%40gmail.com
> Welcome to TriLUG: http://trilug.org/welcome
>


More information about the TriLUG mailing list