#!/usr/bin/perl use strict; sub test($); test 'a'; test 'z'; test 'xyz'; test 'az'; sub test($) { my $s = shift; for my $c (split '', $s) { if ($c !~ /[xyz]/) { print "$s does not match\n"; return; } } print "$s matches\n"; }