#!/usr/bin/perl -W use strict; use English; print "to make the files in the directory symlinks to the files in lectures directory. WARNING: do not use on directories lectures and future, they contain REAL lectures\n"; #the solid direcoty which we wish to turn to sym links my $solid; foreach $solid (@ARGV){ ($solid eq 'lectures') and die "I said, no lectures!"; ($solid eq 'future') and die "I said, no future!"; #list all the files in the directory opendir(DIR, $solid) || die "can't opendir $solid: $!"; # my @lectures = grep { /^\d/ && -f "$solid/$_" } readdir(DIR); my @lectures = grep { /^\d/ } readdir(DIR); closedir DIR; my $lec; print "going to $solid\n"; chdir $solid; foreach $lec (@lectures) { print "$solid/ $lec\n"; system ("rm -f $lec; ln -fs ../lectures/$lec ."); } chdir '..'; print "done with $solid\n"; }