" mean in Perl An example would be much appreciated. The following is an example of where I am reading it: $self->paramet...">

What does "$ <" and "$>" mean in Perl

An example would be much appreciated. The following is an example of where I am reading it:

 $self->parameter( name => 'real_user', xpath => undef, default => scalar(getpwuid($<)) ); $self->parameter( name => 'production', xpath => '/config/production', default => $self->get('user_uid') == $> ); 
+4
source share
2 answers

A $ followed by a character? To perlvar !

$<
The real uid of this process.

$>
The effective uid of this process.

Use them to find out which user is running the program.

+10
source

From perldoc: http://perldoc.perl.org/perlvar.html

 $< 

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

Mnemonics: this is your uid from which you came if you use setuid.

 $> 

The effective uid of this process. For example: 1. $ <= $>; # set real for effective uid2. ($ <, $>) = ($>, $ <); # exchange of real and effective uids You can simultaneously change both effective uid and real uid using POSIX :: setuid (). Changes to $> require $ verification! to detect possible errors after trying to change.

$ <and $> can only be swapped on machines that support setreuid ().

Mnemonics: this is your uid you went to if you use setuid.

+7
source

Source: https://habr.com/ru/post/1486170/


All Articles