#!/usr/bin/perl use strict; use warnings; my $CHR_NUM = $ARGV[0]; my $file_location = "/home/ALL.chr$CHR_NUM.phase1_release_v3.20101123.snps_indels_svs.genotypes.vcf.gz"; my @id_files; # you might find a better variable name for that array of arrays for my $x (1..75) { # $x is a poor name for a variable, perhaps $file_nr would be better my $file_in = "/home/raj/HAPLOTYPES_JAN_2015/PROG_1_Approach_2/C22-$x"; open my $FH, $file_in or die "Cannot open $file_in $!"; # if one fails, you might be happy to know which one of the 75 files while (my $line = <$FH>){ chomp $line; push @{$id_files[$x]}, $line; } close $FH; }