The line in question is the last one. As it is, the output is "hello: hello". But if I put the $_ in quotes:#!/usr/bin/perl sub foo { while (@_) { $_ = shift; $params->{$_} = shift; } print "$_: $params->{$_}\n", for keys %$params; } $_ = shift @ARGV || "world"; foo ( hello => $_ );
You get the expected behavior. why?foo ( hello => "$_" );
In reply to "$_" vs. $_ by argv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |