my @CELLS = ( 'pisbn', 'isbn', 'rendition', ...); my %bookdata; # [...] for my $n (0..13) { if($cell = $sheet->{Cells}[$i][$n]) { my $val = $cell->{Val}; #If you would need the data for later: $bookdata{@CELLS[$n]} = $val; #print"\n--", $val; $getfile = $val; } }