Perl Switch/Case Satement

Written by James McDonald

November 24, 2011



for (@ARGV) {
        if (/^6\d{4}$/)  { $item_code = $_; $action = 'load'; } 
        elsif (/^stop$/) { $action = 'stop' ; } 
        elsif (/^start$/) { $action = 'start'; }
        else { print "Default\n"; }    
}

print "Item : " . $item_code . "\n";
print "Action : " . $action . "\n";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Unifi LAN LOCAL IN OUT

This is a graphic I use to figure out which section to add the firewall rules to in the Unifi UDM/USG controller....