[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: the usage of env



On 2024-07-19, pyh@gmx.it wrote:

> $ perl -le 'for( keys %ENV ){print "$_ --> $ENV{$_}"}' |grep perl
> _ --> /usr/bin/perl
>
> the key for perl is "_" in environment variable? under this key, why
> 'env perl' just works?

Perl $_ is the current (unnamed) value of your loop "for". You could
write it like this:
foreach my $key (keys %ENV) { print "$key=$ENV{$key}" }

https://perldoc.perl.org/variables


Reply to: