in reply to Re^5: Net::SFTP::Foreign error
in thread Net::SFTP::Foreign error
Update: This was intended to be a reply to Re^6: Net::SFTP::Foreign error. Please disregard.
I assume you didn't understand the explanation given in the perlsecret link. Ok, so consider:
@{bareword }(A symbolic reference — sometimes casually called a "soft" reference — only works with package-global variables as used in the example below. That's one reason symbolic references are Officially Frowned Upon; see symbolic references in perlref and also Why it's stupid to `use a variable as a variable name' and also the perlfaq7 FAQ "How can I use a variable as a variable name?" for others. Symbolic referencing also only works when strict 'refs' are disabled.) The "baby cart" just goes one step further and uses an anonymous array constructor [ ... ] to generate an array hard reference to be dereferenced. E.g.:
@{symbolic reference }
@{hard reference }
c:\@Work\Perl\monks>perl -wMstrict -le "no strict 'refs'; ;; our @array = qw(One Two Three); ;; my $soft_ref = 'array'; my $hard_ref = \@array; ;; print @{ array }, '*', @{ $soft_ref }, '*', @{ $hard_ref }; print qq/@{ array }-@{ $soft_ref }-@{ $hard_ref }/; ;; print qq/@{[ something_returning_a_list() ]}/; ;; sub something_returning_a_list { return qw(Nine Eight Seven); } " OneTwoThree*OneTwoThree*OneTwoThree One Two Three-One Two Three-One Two Three Nine Eight Seven
c:\@Work\Perl\monks>perl -wMstrict -le "my ($x, $y, $z) = qw(Fie Foe Fum); my @ra = qw(foo bar baz); ;; my $s = $x . $y . $y . @ra; print $s; " FieFoeFoe3
${bareword }The ${ \$sftp->error } expression simply takes whatever scalar is returned by the method call to $sftp->error and takes a hard reference to it. The hard reference is then dereferenced normally, and the resulting scalar value can be used like any other scalar, e.g., in string interpolation.
${symbolic reference }
${hard reference }
Give a man a fish: <%-{-{-{-<
|
|---|