On Jul 11, Bob Bondi said:

>Thanks for the feedback, everyone.
>My goal for this script is to make "this.gif" and "that.gif" change places
>in the file. I.E.
>-----------------
>this.gif
>that.gif
>this.gif
>-----------------
>
>after running the script I would have
>-----------------
>that.gif
>this.gif
>that.gif
>-----------------
>
>using code like:
>s/$sThis/$sThat/;
>s/$sThat/$sThis/;

I don't know WHAT that $s stuff is.  But the important thing is, you CAN'T
do this in two steps (or two passes).  You have to do it all in one regex:

  #!/usr/bin/perl -pi.bak  # save a filename.bak file
  BEGIN { %opposite = qw( this that  that this ) }
  s/(this|that)/$opposite{$1}/g;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **

Reply via email to