> 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 = ? Yes, a typo... > >>print OUTFILE ($label[$i], "\t"); >>etc. > > $label[$i] =~ s/\(([^]]+)\):/ [$1]/; The $1 seems to be the key to why my early attempts did not work, I tried: $label[$i] =~ s/\(\w+\):/ [\w+]/; blindly hoping that whatever was matched by \w+ would be left alone. I have only used backreferences once...forgot about them...thanks. > >>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"? Sorry, I was rushed when writing my questions...I wanted to evaluate the statement (read: print the substituted variable): '$label[$i] =~ s/\(([^]]+)\):/ [$1]/' within a print statement, i.e.: print OUTFILE (($label[$i] =~ s/\(([^]]+)\):/ [$1]/), "\t"); which prints integers instead...I have just learned that is because substitution returns the number of substitutions performed. ---------------------- Mark J. Yannuzzi myannuzzi@aya.yale.edu ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org