Skip to main content

Image processing

0 likes • Nov 19, 2022 • 0 views
Perl
Loading...

More Perl Posts

Renaming files

0 likes • Nov 19, 2022 • 1 view
Perl
#!/usr/local/bin/perl
#
# rename series of files
#
if ($#ARGV != 3) {
print "usage: rename old new start stop\n";
exit;
}
$old = $ARGV[0];
$new = $ARGV[1];
$start = $ARGV[2];
$stop = $ARGV[3];
for ($i=$start; $i <= $stop; $i++) {
$num = $i;
if($i<10) { $num = "00$i"; }
elsif($i<100) { $num = "0$i"; }
$cmd = "mv $old.$num $new.$num";
print $cmd."\n";
if(system($cmd)) { print "rename failed\n"; }
}

perl hello world

0 likes • Nov 21, 2023 • 7 views
Perl
#!/usr/bin/perl
use strict;
use warnings;
print "Hello, World!\n";

Creating directories

0 likes • Nov 19, 2022 • 2 views
Perl
#!/usr/local/bin/perl
#
# create a series of directories
#
if ($#ARGV != 2) {
print "usage: mkdirs base start stop\n";
exit;
}
$base = $ARGV[0];
$start = $ARGV[1];
$stop = $ARGV[2];
for ($i=$start; $i <= $stop; $i++) {
$num = $i;
if($i<10) { $num = "00$i"; }
elsif($i<100) { $num = "0$i"; }
$cmd = "mkdir $base$num";
print $cmd."\n";
if(system($cmd)) { print "mkdir failed\n"; }
}