sub assert_valid_isbn { local($_) = @_; s/^ISBN\s*// or die "'$_' does not begin with 'ISBN'"; y/- 0-9//cd and die "'$_[0]' contains invalid characters"; /-/ && / / and die "'$_[0]' contains both hyphens and spaces"; y/-/ /; # convert hyphens to spaces. my @g = split; @g == 4 or die "'$_[0]' is broken into the wrong number of groups"; join('',@g) == 10 or die "'$_[0]' contains the wrong number of digits."; }