in reply to Re^3: Object Oriented reference in -textvariable
in thread Object Oriented reference in -textvariable

I found a solution!

Before

-textvariable =>$mockOb->search sub search{ my $self = shift(); if(@_) { $self->{search} = shift(); $self->{search} =~ s/^\s+|\s+$//g; } return $self->{search}; }

After

-textvariable =>$mockOb->searchRef sub searchRef{ my $self = shift(); if(@_) { $self->{search} = shift(); $self->{search} =~ s/^\s+|\s+$//g; } return \$self->{handelspartnerSuche}; }

I do not understand the solution completely, but it seems to work just fine.

Replies are listed 'Best First'.
Re^5: Object Oriented reference in -textvariable
by Corion (Patriarch) on Aug 21, 2017 at 13:29 UTC

    Yes, that's the other approach I mentioned, returning a reference directly from the object.

    Note that the (Java) OO approach would have been to use getters/setters in all cases for writing into the object. If your case is mostly restricted to testing, then that won't make much difference.

    I assume that ->{search} and ->{handelspartnerSuche} should be the same word.