sub valid_flag { # ; Default -d # ; 2x2 -2 # ; 2x2BLD -2b # ; 3x3 -3 # ; 3x3BLD -3b # ; 3x3OH -3o # ; 4X4 -4 # ; 4x4BLD -4b # ; 4x4OH -4o # ; 5x5 -5 # ; 5x5BLD -5b # ; magic -m # ; master magic -mm # ; pyraminx -px # ; pyraminx BLD -pxb # ; megaminx -mx # ; megaminx BLD -mxb # ; square-1 -s # ; square-1 BLD -sb # ; clock -c # ; cup stacking -cs if ($_[0] !~ /^\-([mscxyz]|([2-5s]|[pm]x)b?|[34]o?|mm|cs)$/i) { return 0; } # if the flag entered is not valid, return 0 $_[0] =~ s/-//; $_[0] =~ tr/[A-Z]/[a-z]/; return $_[0]; # however, if it is valid, return it without the - and lowercase }