This is not really about hard versus soft references, but about different data types that happen to have the same name. In the statements
$removed = [ @removed ];
and
$removed = \@removed;
the scalar $removed is the same thing: a hard reference to an array. In the first case, the reference is to an anonymous array created | initialized by a shallow copy from the @removed array. In the second case, the reference is directly to the @removed array. Again, both references are hard references, not soft (or symbolic) references. There are no soft references in the OPed code.
It is a "feature" of Perl that the variables $foo @foo %foo &foo and maybe a few others are all different data types which can be made to have the same name (usually a practice to be avoided, IMHO).
Update: Here's some code that might give a better idea of what's going on:
c:\@Work\Perl\monks>perl -wMstrict -le "use Data::Dump qw(pp); ;; my @ra = qw(a b c d); print 'A: ', pp \@ra; ;; my $hardref = [ @ra ]; print 'B1: ', pp $hardref; pop @{$hardref}; print 'B2: ', pp $hardref; print 'B3: ', pp \@ra; ;; $hardref = \@ra; pop @{$hardref}; print 'C1: ', pp $hardref; print 'C2: ', pp \@ra; " A: ["a" .. "d"] B1: ["a" .. "d"] B2: ["a", "b", "c"] B3: ["a" .. "d"] C1: ["a", "b", "c"] C2: ["a", "b", "c"]
Give a man a fish: <%-{-{-{-<
In reply to Re: hard versus soft reference to ARRAY's
by AnomalousMonk
in thread hard versus soft reference to ARRAY's
by teun-arno
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |