Thread preprocessor replacement
(8 answers)
Opened by perltiptop at 2009-04-07 23:49
So könnte es gehen:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #!/usr/bin/perl use strict; use warnings; my $filein ='/path/to/in/file.c'; my $fileout='/path/to/out/file.c'; open(my $fhin, '<', $filein) or die "ERROR open $filein ($!)\n"; open(my $fhout, '>', $fileout) or die "ERROR open $fileout ($!)\n"; while(my $line=<$fhin>) { # suchen und ersetzen $line=~s/(^\s*#\s*if\(\s*)MY_OLD_CONST\s*==\s*1(\s*\))/$1MY_NEW_CONST == 5$2/; print $fhout $line; } close($fhout); close($fhin); |