The script below is based upon the Text::CSV documentation:

use Modern::Perl; use Text::CSV; my @Sample_Ids_m; my $csv = Text::CSV->new( { binary => 1 } ) # should set binary att +ribute. or die "Cannot use CSV: " . Text::CSV->error_diag(); while ( my $row = $csv->getline(*DATA) ) { push @Sample_Ids_m, $row->[6]; # Element 6 is the ID } say for @Sample_Ids_m; # Print the collected I +Ds __DATA__ John Doe,G building,05-Aug-2012,08-Aug-2012,"New York City, NY",ABC234 +5,UCD23467, John Moe,H building,05-Aug-2012,08-Aug-2012,New York City,DEF2345,UCD8 +0645, John Slo,I building,05-Aug-2012,08-Aug-2012,New York City,GHI2345,UCD7 +6765, John Hor,j building,05-Aug-2012,08-Aug-2012,New York City,JKL2345,UCD8 +7111,

Output:

UCD23467 UCD80645 UCD76765 UCD87111

Adapted for your csv file (untested):

use Modern::Perl; use Text::CSV; my @Sample_Ids_m; my $csv = Text::CSV->new( { binary => 1 } ) # should set binary att +ribute. or die "Cannot use CSV: " . Text::CSV->error_diag(); open my $fh, "<", "Merged_CSVfiles.csv" or die "Merged_CSVfiles.csv: $ +!"; while ( my $row = $csv->getline($fh) ) { push @Sample_Ids_m, $row->[16]; # Element 16 is the ID } $csv->eof or $csv->error_diag(); close $fh; say for @Sample_Ids_m; # Print the collected I +Ds

From your code above, it looks like the ID is the 16th element in @columns, and the $row->[16] notation grabs it after parsing a csv line. See if this may assist your scripting...


In reply to Re^5: Why is the following instance of Matching using an array element not working by Kenosis
in thread Why is the following instance of Matching using an array element not working by MyJeweledPerls

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.