If your class lends itself to the technique, you could use an lvalue method and avoid the need to copy anything.
#! perl -slw use strict; package Test; sub new{ my( $class, $value ) = @_; return bless { content => $value }, $class; } sub content : lvalue { my( $self ) = shift; $self->{ content }; } 1; package main; my $thing = Test->new( 'empty' ); print $thing->content; $thing->content = 'the quick brown fox'; print $thing->content; $thing->content =~ s[\b(.)][\U$1]g; print $thing->content; __END__ P:\test>368057 empty the quick brown fox The Quick Brown Fox
In reply to Re: regex transforms of object attributes
by BrowserUk
in thread regex transforms of object attributes
by Tuppence
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |