Do not use $_ as a temporary variable unless essential.#!/usr/bin/perl use strict; use warnings; sub foo { my %params = @_; print "$_: $params{$_}\n", for keys %params; } my $word = shift @ARGV || "world"; foo ( hello => $word );
Declaring and naming the variable catches a lot of issues and solves (for example) the problem you came across as well as improving readability.
In reply to Re: "$_" vs. $_
by Brovnik
in thread "$_" vs. $_
by argv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |