Help for this page

Select Code to Download


  1. or download this
    my $valid_chars = 'CETLMNPA';
    if ($CD =~ m/^[$valid_chars](?:,[$valid_chars])*$/) {
    ...
    else {
       die "Invalid!"
    }
    
  2. or download this
    m/
       ^[$valid_chars]   #the string must start with one of the valid char
    +s
    ...
       )*                #and that comma+valid char could repeat 0 or more
    + times
       $                 #until the end of the string
    /x                   #this is here to allow me to use all these commen
    +ts
    
  3. or download this
    my %config = map { $_ => 1 } split(',', $CD);
    ## later on...
    if ( $config{L} ) { print "L was set!" }