That's pretty awesome RBB.
Trying my hand at Perl, just wrote a quick thing to count up the number of marks in various past papers in my Past_Papers folder (Ubuntu).
It's looking for a string of digits between ~( and ) by the way.
Perl code:
#!/usr/bin/perl -w
print("Enter subject you're looking for: ");
my $target = <STDIN>;
chomp($target);
my $numdocs = 0;
my $dirname = "/home/thomas/Past_Papers";
opendir(DIR, $dirname) or die;
while(my $filename = readdir(DIR))
{
my $count = 0;
if($filename =~ /^\./)
{
next;
}elsif($filename =~ /$target/i)
{
$numdocs++;
open (FILE, $dirname."/".$filename) or die;
my $linenum = 0;
while(<FILE>)
{
$linenum++;
my ($temp) = /~\((\d+)\)/;
if($temp){$count += $temp;}
}
if($count > 0) { print("$filename, ($count)\n"); }
}
}
if($numdocs == 0)
{
print("No matches\n");
}
Last edited by Fear; Apr 6, 2014 at 06:38 PM.