#! /usr/bin/perl -w

$hashbang = "#! /usr/bin/env python\n\n";

# Get the list of example directories

@exdirs = <debian/*/usr/share/doc/*/examples>;

# Find the example scripts in those directories which are not yet marked
# as executable

@exscripts = ();
foreach $exdir (@exdirs) {
	push @exscripts, 
		split("\n", `find $exdir -name '*.py' -a \! -perm +111`);
}

# Add the interpreter line to those scripts and make them executable

foreach $exscript (@exscripts) {
	print "Making $exscript executable\n";
	system(qq{perl -pi -e 'print "$hashbang" if \$. == 1' $exscript});
	system(qq{chmod a+x $exscript});
}
