in reply to translate arglist
Of course you might have to adjust the regexes a bit, taking care of whitespace, ... but I think you get the idea.use constant SEARCH => 0; use constant REPLACE => 1; my %translate = ( funca => [ qr/funca\( ([^,]+) , ([^,]+) ,([^,]+) ,([^)]+) \)/x, '"func($1,$2,XXX,YYY,$4)"' ], funcb => [ qr/funcb\( ([^,]+) , ([^,]+) ,([^,]+) ,([^)]+) \)/x, '"func($1,$2,,,$4)"' ], ); while (<DATA>) { for my $key (keys %translate) { if (/$key/) { s/$translate{$key}->[SEARCH]/$translate{$key}->[REPLACE]/e +e; print; } } } __DATA__ funca(10,20,30,40) funcb(10,20,30,40)
-- Hofmator
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: translate arglist
by denap (Initiate) on Feb 04, 2003 at 16:51 UTC |