WeBWorK Problems

need a shell script

Re: need a shell script

by Gavin LaRose -
Number of replies: 0
Hi Darwyn,

The following may do what you want. It runs in the directory containing the PG files you want to change.

#!/usr/bin/perl -w
use strict;

foreach my $f ( `ls *.pg` ) {
    my $file = `cat $f`;
    chomp( $f );
    if ( $file !~ /PGcourse\.pl/ ) {
	$file =~ s/(loadMacros\([^)]+?),?(\s*)\);/$1, $2"PGcourse.pl",\n);/s;
	open( OF, ">$f" );
	print OF $file;
	close(OF);
	print "$f.. ";
    } else {
	print "[$f].. ";
    }
}
print "done\n";

Gavin