When I first learned perl I wrote the classic "replace text in files" script
that probably everybody else writes.  It is run with:

  % replace 'sometext' 'some other text' <files>

... where $match gets the first arg, and $replace gets the second.  It
didn't work at first, but someone on this list recommended that I use:

  s/$match/qq(qq($replace))/gmee;

Something magical about the paired "qq("s and "e"s makes it work.

Yesterday I finished a unit converter, and I thought, "Wouldn't it be great
to be able to convert units on a column of data in a file?"  (I don't want
to use awk because it messes up nicely lined up columns.)

But this doesn't work:

  % replace '^((\s*\S*){8}\s*)(\S*)' '${1}qx(do -uc $3 in cm)'

Any ideas why "qx" wouldn't work inside of my s/// operator above?

- B



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to