Conditionally replace nth column of every function call
I have very large perl source code file and I want to replace every occurrence function say foo,The function foo has some arguments and I want to replace 2nd argument,the current argument is hex integer and i want to replace it to equivalent string.Also I want to replace function name foo with bar_new e.g.
Code:
foo(a,0x1,b,c,d) should be replaced with bar_new(a,$some_obj->one,b,c,d) |
Quote:
That said, you can run "sed -i 's/foo/bar_new/g' <filename>" to replace the foo part. Then "sed -i s/a,.*,b/a,$some_object,b/g' <filename>". There are MANY easily-found sed tutorials you can reference. |
Code:
#!/usr/bin/perl perl script.pl file ... will run it to look at. perl -i_ script.pl file ... will replace and backup to file_ |
All times are GMT -5. The time now is 04:39 AM. |