Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$> and $? in Perl

In Perl, do $> and $? have special meaning in the same way that $_ and @_ are "special"?

like image 354
funk-shun Avatar asked Dec 13 '22 13:12

funk-shun


1 Answers

Yes, there are many special variables whose name is a single punctuation character, including the scalar variable > (written $>) and the scalar variable ? (written $?). They are documented in perldoc perlvar.

$> is the process's effective user ID. It's “magical” in that assigning to it will change the EUID (if permitted).

$? contains the status of the last external process call. It's a little magical (e.g. you can only assign integers to it), but mainly several built-in constructs (such as backticks, i.e. `foo`) assign to it.

like image 81
Gilles 'SO- stop being evil' Avatar answered Feb 14 '23 02:02

Gilles 'SO- stop being evil'