if (...) { ... return; } ... # "else" stuff #### while (<$channel>) {push @output, $_} #becomes push @output, $_ while <$channel>; #although my @output = <$channel>; #is even better #### for my $i (@show_inventory) { my $inv_line1 = shift @show_inventory; my $inv_line2 = shift @show_inventory; #### while (@show_inventory) { my $inv_line1 = shift @show_inventory; my $inv_line2 = shift @show_inventory;