print "real: $<, effective $>\n"; $> = 1000; # drop privileges print "real: $<, effective $>\n"; { # locally regain privileges local $> = 0; $> == 0 or die "Insufficient privileges, run script as root"; print "real: $<, effective $>\n"; } # unprivileged again print "real: $<, effective $>\n";