slitaz-dev-tools diff baba-scripts/rename.pl @ rev 309

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 26 08:23:49 2019 +0100 (2019-02-26)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/baba-scripts/rename.pl	Tue Feb 26 08:23:49 2019 +0100
     1.3 @@ -0,0 +1,22 @@
     1.4 +#! /usr/bin/perl
     1.5 +$testmode = 0;  #false
     1.6 +if ($ARGV[0] eq '-t') {
     1.7 +   $testmode = 1;  #true
     1.8 +   shift;
     1.9 +}
    1.10 +($regexp = shift @ARGV) || die "Usage:  rename [-t] perlexpr [filenames]\n-t : option to test action (nothing really done)\n";
    1.11 +if (!@ARGV) {
    1.12 +   @ARGV = <STDIN>;
    1.13 +   chomp(@ARGV);
    1.14 +}
    1.15 +print "Test mode\n" if ($testmode);
    1.16 +foreach $_ (@ARGV) {
    1.17 +   $old_name = $_;
    1.18 +   eval $regexp;
    1.19 +   die $@ if $@;
    1.20 +   unless ($old_name eq $_) {
    1.21 +	   print "$old_name -> $_\n";
    1.22 +	   rename($old_name, $_) unless $testmode;
    1.23 +   }
    1.24 +}
    1.25 +exit(0);