in reply to \ as a binary operator
You do realise that $_[0] is an alias to the item passed to the subroutine so you don't need to pass a reference to do the same thing:
$ perl -le' sub head($) { my ($x, $xs) = split( " ", ${$_[0]}, 2); ${$_[0]} = $xs; return $x; } my $msg = "new item x"; my $cmd = head \ $msg; print for $cmd, $msg; ' new item x $ perl -le' sub head { my ($x, $xs) = split( " ", $_[0], 2); $_[0] = $xs; return $x; } my $msg = "new item x"; my $cmd = head $msg; print for $cmd, $msg; ' new item x
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: \ as a binary operator
by dk (Chaplain) on Jul 01, 2009 at 23:11 UTC |