NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Do it in Perl (Score:2)
- Read in all the lines of the file
- Walk thru the lines finding the one with bind parm 1. That's line $x.
- Make sure that $line[$x+1] is bind parm 2, or else die because your heuristic isn't right.
- @line[$x,$x+1] = @line[$x+1,$x];
- $line[$x] =~ s/2/1/;
- $line[$x+1] =~ s/1/2/;
Or thereabouts. Seems to me that you don't need to switch the parms, but rather switch their bind numbers.It's a quick throwaway tool, but that's OK that you're going to throw it away. Better yet, keep it in some CVS project (we call ours "lab") that acts as a junk drawer, so you have it later on if you need to do something similar in the future.
--
xoa
Reply to This
Re:Do it in Perl (Score:1)
perl -0777 pi.bak -e 's/\(1, ([^\)]+)\)(.*?)\(2, ([^\)]+)\)/(1, $3)$2(2, $1)/gs' file.plDisclaimer: Not tested extensively.