Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does < do in Perl in this instance?

Tags:

syntax

cgi

perl

I am confused as to what the second line does in this snippet of code. $runas should be evaluated to the user's uid i think. What does the $< do? This is contained in a CGI script.

my $runAS = (getpwnam("username"))[2];
$runAS = $< if ($runAS == 0);
like image 386
aglassman Avatar asked Nov 30 '22 23:11

aglassman


1 Answers

$< is a special variable in perl:

The real uid of this process. You can change both the real uid and the effective uid at the same time by using POSIX::setuid() . Since changes to $< require a system call, check $! after a change attempt to detect any possible errors.

like image 119
vstm Avatar answered Dec 04 '22 02:12

vstm