return SF->new ("$lhs->{str}$rhs->{str}", $lhs->{list}, $rhs->{list});
Shouldn't the merging of the lists look something like
... return SF->new ( "$lhs->{str}$rhs->{str}", [ map ref($_) eq 'ARRAY' ? @$_ : (), $lhs->{list}, $rhs->{list} ] );
Another issue (which I don't have a solution for) is that what's LHS and RHS seems to vary with the circumstances of the concatenation, i.e. while this
my $name1 = SF->new ('GrandFather', [1, 2, 3]); my $name2 = SF->new (' and Almut', [4, 5, 6]); my $catStr = $name1 . $name2; use Data::Dumper; print Dumper $catStr;
produces (as expected)
$VAR1 = bless( { 'str' => 'GrandFather and Almut', 'list' => [ 1, 2, 3, 4, 5, 6 ] }, 'SF' );
"Name is $name1" (or "Name is " . $name1) doesn't :
$VAR1 = bless( { 'str' => 'GrandFatherName is ', 'list' => [ 1, 2, 3 ] }, 'SF' );
(note that "Name is " is appended to "GrandFather", not the other way round)
In reply to Re^2: redefining string interpolation
by almut
in thread redefining string interpolation
by perl5ever
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |