Skip to content

Instantly share code, notes, and snippets.

@carlosmcevilly
Created March 25, 2014 22:26
Show Gist options
  • Save carlosmcevilly/9772781 to your computer and use it in GitHub Desktop.
Save carlosmcevilly/9772781 to your computer and use it in GitHub Desktop.
Remove most legal boilerplate from an Apple sample project. For testing/research purposes only.
#!/usr/bin/perl
use strict;
use warnings;
my $path = $ENV{'XcodeProjectPath'};
$path =~ s{(.*)/\w+\.xcodeproj}{"$1"};
my $cmd = "/usr/bin/find $path -type f -name \"*.[mh]\" -print";
my $files = qx($cmd);
my @files = split("\n", $files);
foreach my $file (@files) {
fix_file($file);
}
sub fix_file {
my $file = shift;
open(IN, $file) or die "unable to open $file for reading: $!";
my @data = <IN>;
close(IN);
my $data = join('', @data);
my $start = "Disclaimer:\\s+(?:IMPORTANT:\\s+)?This Apple software";
my $end = "POSSIBILITY OF SUCH DAMAGE\\.";
$data =~ s{\s*$start.*?$end\s*?(\n.*)}{$1}sg;
open(OUT, '>', $file) or die "unable to open $file for writing: $!";
print OUT $data;
close(OUT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment