Copyright header substitution script powered by perl.
Most people think that I'm some kind of Python crazy fan, while I actually enjoy learning new programming languages. I haven't write anything useful in perl before, although I've played with it.
But last week I had to replace a lot of copyright/license headers in a bunch of code, and I thought it was a good idea to use perl for it. It took my some effort to find an example on how to do this on the web, so I thought posting the code would be a good idea, enjoy.
#!/usr/bin/perl
foreach $arg (@ARGV) {
open(SOURCE, $arg);
@lines = <SOURCE>;
$source = join("", @lines);
close(SOURCE);
$header = "/*
*
* This is my new copyright header. (c) 2007
* All rights reversed.
*
*/";
$_ = $source;
s/\/\*(?:.|[\r\n])*?\*\//$header/;
$source = $_;
open(SOURCE, ">$arg");
print SOURCE $source;
close(SOURCE);
}
It could be probably less verbose or more perlish, if you have suggestion on how to improve it, feel free to post comments.

