my $string = 'w/';

if ($string =~ m~^[^0-9a-z]~i) {
    print 'Only a-z0-9 allowed'
} else {
    print 'Apparently valid.'
}