I'm trying to create 23 arrays without typing out @array1
, @array2
, and so on, and load them each with the variables from the array @r
if the $chrid
matches the array number (if $chrid=1
it should be placed in @array1
). How can I achieve this?
Here is what I have so far:
#!/usr/bin/perl
use warnings;
use strict;
my @chr;
my $input;
open ($input, "$ARGV[0]") || die;
while (<$input>) {
my @r = split(/\t/);
my $snps = $r[0];
my $pval = $r[1];
my $pmid = $r[2];
my $chrpos = $r[3];
my $chrid = $r[4];
for ($chrid) {
push (@chr, $chrid);
}
}
close $input;