Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- #
- foreach $arg (@ARGV){
- if (($arg eq "-t")||($arg eq "-d")){
- $option = $ARGV[0];
- next;
- }
- $search = uc($arg);
- $url = "http://www.timetable.unsw.edu.au/current/$search.html";
- open F, "wget -q -O- $url |" or die "cannot open the webpage\n";
- @lines = <F>;
- $sem = "null\n";
- $len = @lines;
- $i = 0;
- while ($i < $len){
- $pre = $sem;
- $day = "null";
- $time = "null";
- if (($lines[$i] =~ /Lecture/ig) and !($lines[$i] =~ /Sequence/ig)){
- $j = $i + 3;
- if ($lines[$j] =~ /([XS][12])/gi){
- $sem = $1;
- $j += 3;
- chomp($lines[$i]);
- $lines[$j] =~ s/<.*?>//ig;
- $lines[$j] =~ s/^\s+/ /ig;
- if (defined($option)){
- while($lines[$j] =~ /([A-Z][a-z]{2})[^A-Za-z]?([0-9]{2}:[0-9]{2})( - )([0-9]{2}:[0-9]{2})/cig){
- $day = $1;
- $time = $2;
- $time =~ s/:/./;
- $time_e = $3;
- $time_e =~ s/:/./;
- if ($time ne $pre){
- if ($option eq "-d"){
- $time = int($time);
- $time_e = int($time_e + 0.99);
- print "start : $time\n";
- print "end: $time_e\n";
- #while ($k < $time_e){
- # printf "%s %s %s %s\n",$sem, $search, $day, $k;
- #}
- }
- }
- }
- }
- else {
- $sem .= $lines[$j];
- chomp ($sem);
- if (($pre ne $sem) && !($sem =~ /[XS][12][ ]$/gi)){
- printf "%s: %s\n", $search, $sem;
- }
- }
- }
- }
- $i += 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement