#! perl -slw use strict; sub other{ print "Processing '$_[0]' with arg: '$_[1]'" } my %dispatch = map{ $_ => \&other } 'b'..'z'; $dispatch{a} = sub { print "\nNew section\nProcessing 'a' with arg '$_[1]'"; }; while( ) { chomp; $dispatch{$1}->( $1, $2 ) while m/ \] ( [a-z] ) \[ ( [^]]+ ) /xg; } __DATA__ ...