I have worked with Text::CSV in the past. I have only slight issue with it, which I am not sure if I am not getting how to use it correctly. Here is the following code:
my $csv = Text::CSV->new(); open (CSV,"<", "Merged_CSVfiles.csv") || die "File not found\n"; while (<CSV>) { # While Loop Open Bracket next if ($. == 1); if ($csv->parse($_)) { #If Open Bracket my @columns = $csv->fields(); #__ Assigning $columns[0]-$columns[26] to variables my @Sample_Ids_m = $columns[16]; print ($Sample_Ids_m[0]); } else { # If Closed Bracket # Else Open Bracket my $err = $csv-> error_input; print "Failed to parse line: $err"; close CSV; } # Closed Else Bracket }#Closed While Loop Bracket
All the ID are loaded into the first element of the array @Sample_Ids_m. This would be a problem but arrays can be different lengths and there are no rules current for constructing Sample ID numbers. It is a random sort of thing.
If there was some uniformity I could use the substr function and a for loop and extract our individual id's but I dont seem to be able too. I will play around with it for a bit more
In reply to Re^4: Why is the following instance of Matching using an array element not working
by MyJeweledPerls
in thread Why is the following instance of Matching using an array element not working
by MyJeweledPerls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |