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

Re: [MacPerl-AnyPerl] Multiple Substitution



At 13.03 -0400 1999.05.05, 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]'
>
>and find that the brute force approach, of course, works:
>
>$label[$i] = s/\(/ [/;
>$label[$i] = s/\):/]/;

Assume you mean =~, not = ?

>print OUTFILE ($label[$i], "\t");
>etc.

$label[$i] =~ s/\(([^]]+)\):/ [$1]/;

>I tried, unsuccessfully, to combine the two substituitions into one
>statement, and put it into the 'print' statement. Two questions:
>
>1) Is there a way to combine the two substitution statements into one?
>2) Why do substitution statements not work when placed in the 'print'
>function?

I don't understand what you mean.  "Doesn't work" doesn't mean anything to
me by itself.  What do you want to do, and what does it do instead?  What
does the code look like that "doesn't work"?

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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