#!/usr/bin/perl -w use strict; use File::Find; my $topdir = shift || '.'; my $filemode = shift || 0644; my $dirmode = shift || 0755; find(\&doit, "$topdir"); #this sub works fine sub doit { return if -d and /^\.\.?$/; chmod($filemode, $_) if (-f $_); chmod($dirmode, $_) if (-d $_); }