... foreach my $worksheet (@{$excel_sheet -> {Worksheet}}) { $worksheet -> {MaxRow} ||= $worksheet -> {MinRow}; # Skip worksheet if it doesn't contain data. next if $worksheet -> {MinRow} > $worksheet -> {MaxRow}; foreach my $row ($worksheet->{MinRow} .. $worksheet->{MaxRow}) { # Send flag as DONE once it reach the end of file or if there is no data send_data( zipcode => 'DONE', # Flag ); # Correct values or skip them: next unless defined $worksheet->{Cells}[$row][0]->{Val}; warn Dumper $worksheet->{Cells}[$row][0]->{Val}; if ( $worksheet->{Cells}[$row][0]->{Val} =~ /^\d{5}/ ) { my $xlsx_rows = $worksheet->{Cells}[$row]; # Send data send_data( zipcode => $xlsx_rows->[0]->{Val} || '', firstname => $xlsx_rows->[1]->{Val} || '', lastname => $xlsx_rows->[2]->{Val} || '', ); } } } ...