[GRLUG] Some perl help

David Pembrook david at pembrook.net
Sat Jul 2 14:33:29 EDT 2011


I'm fluent enough in perl to be dangerous.  I have a line from a csv 
file and I want the "columns" in an array without any quotes. Some 
columns have them, some don't so I can't count on their presence.

The quick and dirty way I came up with used a temp array and a counter 
and know that has to be a better way to handle this.

         while (<FILE>) {

             @temp_values2 = split(",", $_);

             $counter=0;
             foreach $temp_val (@temp_values2) {
                 $temp_val =~ s/"//g;
                 $temp_values[$counter] = $temp_val;
                 $counter++;
             }

             ..... more code to process the line follows

         }


I also see that $temp_values isn't reset each loop either and values 
from a previous line with more columns would still be present.  Any 
thoughts?

Thanks,
Dave


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the grlug mailing list