Help for this page

Select Code to Download


  1. or download this
    for ($variable_to_test) {   
        if    (/pat1/)  { }     # do something 
    ...
        elsif (/pat3/)  { }     # do something else
        else            { }     # default
    }
    
  2. or download this
    SWITCH: for (ref $whatchamacallit) {
        
    ...
        warn "User defined type skipped";
    
    }
    
  3. or download this
    chomp($answer = <>);
    if    ("SEND"  =~ /^\Q$answer/i) { print "Action is send\n"  }
    ...
    elsif ("ABORT" =~ /^\Q$answer/i) { print "Action is abort\n" }
    elsif ("LIST"  =~ /^\Q$answer/i) { print "Action is list\n"  }
    elsif ("EDIT"  =~ /^\Q$answer/i) { print "Action is edit\n"  }
    
  4. or download this
    my %commands = (
        "happy" => \&joy,
    ...
    } else {
        print "No such command: $string\n";
    }