At 10:19 pm -0800 17/1/04, Kim Helliwell wrote:


I need to take a string like this:

UA-UI1,3,4,6

and expand it into an array of components like this:

UA1 UA3 UA4 UA6 UB1 UB3 UB4 UB6 ... UI1 UI3 UI4 UI6

How about this:



$_ = "UA-UI1,3,4,6"; m~(..)\-(..)(\d.+)~; for $CC( $1 .. $2 ) { for $n ( split /,/, $3 ) { print "$CC$n "} }


UA1 UA3 UA4 UA6 UB1 UB3 UB4 UB6 UC1 UC3 UC4 UC6 UD1 UD3 UD4 UD6 UE1 UE3 UE4 UE6 UF1 UF3 UF4 UF6 UG1 UG3 UG4 UG6 UH1 UH3 UH4 UH6 UI1 UI3 UI4 UI6

Reply via email to