All pastes #884965 Raw Edit

the thing-v3

public text v1 · immutable
#884965 ·published 2008-01-30 18:20 UTC
rendered paste body
use strict;
use warnings;

use Getopt::Std;
my %opt;
getopts('e:',\%opt) or die;
die unless exists $opt{e};

opendir(HERE,'.') or die "Epic failure.\n";
my @paths = readdir(HERE);
closedir(HERE) or warn "Whatever.\n";

open(DATA,"data.txt") or die "Rename your text file 'data.txt'.\n";
my @data;
while(<DATA>) {
  chomp;
  next unless length;
  push(@data,$_);
}
close(DATA) or warn "Whatever two.\n";

foreach my $path (@paths) {
  next unless $path =~ /.*\.$opt{e}$/i;
  my $newpath = sprintf('%s.%s',shift @data,$opt{e});
  rename($path,$newpath);
}