in reply to Re^4: Case Statement
in thread Case Statement

It depends on what you want exactly, but here's something that might work for you:
case (/LotID/i) { @lotid = split( /-/, $array[1] ); $lotid = "$lotid[0]"; # fetch the part matching Lot#XXX where XXX is one or + more digits, or die if that doesn't work ($lotid) = $lotid =~ /(Lot#\d+)/ or die "lotid isn't c +orrectly formatted"; $wafer_flow = "$lotid[1]-$lotid[2]"; }
The ($lotid) = ... line makes use of several tricks:

1. assigning the result of a regex match to a list will assing the () delimited parts of that regex to the the members of the list. In this case, there's only one member in the list ($lotid) and one () delimited submatch, so $lotid will get the value of whatever is matched by Lot#\d+

2. the result of assignment to a list is the number of elements assigned to. in this case, 1 if the regex matches or 0 if the regex doesn't match. The ... or die ... part tests for that value and throws an exception if the match failed, since in that case my logic is wrong.

For a reasonably genteel introduction to regexes see perlretut. For (most of) the whole story, see perlre.

As an aside, please consider dropping Switch altogether, it's a fun module but one day it will cause hard to debug problems.