]> sjero.net Git - wget/blobdiff - util/rmold.pl
NEWS: cite --start-pos
[wget] / util / rmold.pl
index f68744b197d04bf8323d910b0fbbd44e76ee6177..b7ddecf9b0f6623429475a3945906aa544745286 100755 (executable)
@@ -1,10 +1,11 @@
-#! /usr/bin/perl -w
+#!/usr/bin/env perl -w
 
-# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1995, 1996, 1997, 2007, 2008, 2009, 2010, 2011 Free
+# Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 
 # This program is distributed in the hope that it will be useful,
@@ -13,8 +14,7 @@
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # This script is a very lame hack to remove local files, until the
@@ -31,10 +31,8 @@ if (@ARGV && ($ARGV[0] eq '-v')) {
     $verbose = 1;
 }
 
-defined($dirs[0] = shift) || ($dirs[0] = '.');
-while (defined($_ = shift)) {
-    @dirs = (@dirs, $_);
-}
+(@dirs = @ARGV) || push (@dirs,'.');
+
 
 foreach $_ (@dirs) {
     &procdir($_);
@@ -44,28 +42,28 @@ foreach $_ (@dirs) {
 
 sub procdir
 {
-    local($dir = $_[0]);
+    local $dir = shift;
     local(@lcfiles, @lcdirs, %files, @fl);
 
     print STDERR "Processing directory '$dir':\n" if $verbose;
-    
+
     opendir(DH, $dir) || die("Cannot open $dir: $!\n");
     @lcfiles = ();
     @lcdirs = ();
     # Read local files and directories.
     foreach $_ (readdir(DH)) {
         /^(\.listing|\.\.?)$/ && next;
-        if (-d "$dir/$_" || -l "$dir/$_") {
-            @lcdirs = (@lcdirs, $_);
+        lstat ("$dir/$_");
+        if (-d _) {
+            push (@lcdirs, $_);
         }
         else {
-            @lcfiles = (@lcfiles, $_);
+            push (@lcfiles, $_);
         }
     }
     closedir(DH);
     # Parse .listing
     if (open(FD, "<$dir/.listing")) {
-        @files = ();
         while (<FD>)
         {
             # Weed out the line beginning with 'total'