in reply to chmod in perl script

I think we've answered this in the chatterbox. My suggestion was

my @s = lstat $dirname or die "stat $!"; -l _ and die "islink $!"; chmod+($s[2] | 02000), $dirname or die "chmod";

If you prefer symbolic constants, you can use Fcntl "S_ISGID"; and then write S_ISGID() instead of 02000.

You could also try the File::chmod module to use symbolic mode letters.