#!/usr/bin/perl use warnings; use strict; opendir(DIR, '.'); my @files = grep !/^\.{1,2}$/, readdir DIR; #no . or .. @files = grep /08|09/, @files; #only 08 09 files closedir DIR; print "@files\n"; my @commands; foreach my $file (@files){ my $string = `ls -l|grep $file`; push @commands, [$file, $string]; # push arrayref } print join "\n", @commands,"\n"; foreach my $arrayref( @commands){ print $arrayref->[0]. "\t=\t". $arrayref->[1],"\n"; }