sub head($) { my ($x, $xs) = split( ' ', ${$_[0]}, 2); ${$_[0]} = $xs; return $x; } #### my $msg = "new item x"; my $cmd = head \ $msg; if ( $cmd eq 'new') { if ( head \ $msg eq 'item') { ... } } elsif ( $cmd eq 'set') { ... }