#!/usr/bin/perl use strict; use warnings; use Getopt::Std; use File::Find; my %opts; getopts('w:s:d:p:h', \%opts); #Options stand for width, source, and destination respectively $opts{s} = "./" unless $opts{s}; if ($opts{h}){ print <", $infile, "$opts{d}/$1.jpg"); } else { warn "File ($infile) does not match naming convention; skipping."; } } } while (my @batch = splice(@files, 0 , $batch_size)) { unless ($pid = fork()) { resize(@batch); exit; } if (defined $pid){ push @children, $pid; } else { die "Failed to fork!"; } } foreach (@children){ wait; }