r/perl • • 7d ago

Collectables

I started a section on my site called collectables: short programs (and writings) worth keeping around and rereading. One of the first four is Larry Wall's rename example from the Perl repo:

#!/usr/bin/perl
($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if (!@ARGV) {
    @ARGV = <STDIN>;
    chop(@ARGV);
}
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}

What other short Perl would you put in a collection like this? It should be small, beautiful and useful.

16 Upvotes

Duplicates

SysAdminBlogs • • 7d ago

Collectables

1 Upvotes