[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] Multiple Substitution



Mark Yannuzzi wrote:

>I want to transform and print to a file the following form of text, which
>are stored in an array:
>
>$label[$i] = 'VD(mA):'
>
>I want to transform them to the following form:
>
>$label[$i] = 'VD [mA]'

Why not take a different, far more flexible angle?

	for ($label[$i]) {   # $_ is alias
		/(\w+)\((\w+)/ and $_ = "$1 [$2]";
	}

Advantage: if you ever want to completely turn around the output format,
you're free to do so. The more "hardwired" solutions like those
presented so far, are not so flexible.

	Bart.

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org