Hello, I'm having a problem trying to add arrays to an array. My purpose is to see if each files have the same first columns, and output a file that doesn't have the same columns. All the files follow the same table format(tab delimited). So from each file, i took out the first column and stored it to an array(@row1). And i stored those arrays of first column in to another array @row. However, when i run it, @row doesn't contain array but number of columns. when i print $row [0] , $row[ 2) or etc, it will print numbers not the array of columns i intended to store. can someone tell me how i can fix this problem?

#!/usr/bin/perl -w use strict; use warnings; use File::Basename; die "Usage: perl extracting.pl [directory where files are located] \n +" unless ($#ARGV ==0); my ($folderin) = @ARGV ; #$dirname = "/data/lgsg/yuho/ProjectSuccess.extracting2columns/sort/ge +neReadCount" opendir(DIR, "$folderin") || die "cannot openfolder"; my @list = readdir (DIR); closedir(DIR); for(1..2){shift @list;} my ($filecount, $rowcount) = 0 ; my (@filename, @row); foreach my $fileone (@list) { $filename[$filecount] = $fileone; open(RES,"$folderin/$fileone") || die "could nottt open $fileone\n +"; <RES>; <RES>; my $count = 0; my $row1; my @genes; while(<RES>){ $row1[$count] =(split /\t/)[0]; $count++; } $row[$filecount] = @row1; $filecount++; } my $unmatched = 0 ; my @names; my $filecount1 =$filecount-1; for (my$chr =1; $chr <= $filecount1; $chr++){ if ($row[0] ne $row[$chr]) { $names[$unmatched] =$filename[$chr]; $unmatched++; } } print "Total # of files compared: $filecount \n"; print "Total # of files unmatched: $unmatched\n"; print "name of the files unmatched : @names \n " ;

In reply to adding arrays to an array by coolda

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.