in reply to Is this bad coding style?

I know this is just an example, but strict and warnings can help nonetheless. In this case you define @arrray and loop over @array. OK, that's out of my system. :-)

A dispatch table might help, especially if you've got a lot of special cases. For example:

my %dispatch = ( '#' => \&sub1, 1 => \&sub2, ); my @array = (1, 2, 3, '#', 6, 7, '#', 9, 10); # corrected typo! foreach (@array) { if( exists $dispatch{$_} ) { $dispatch{$_}->(); } else { sub3(); }