Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: regex transforms of object attributes

by belden (Friar)
on Jun 19, 2004 at 16:21 UTC ( [id://368184]=note: print w/replies, xml ) Need Help??


in reply to Re^3: regex transforms of object attributes
in thread regex transforms of object attributes

This will not break due to changes in $obj's interface

my $content = $obj->content(); $content =~ s/ome/thin/g; $obj->content( $content );

This might

$obj->{content} =~ s/ome/thin/g;

The former uses the interface published by the module author. The latter relies on the internal workings of the object itself, and therefore violates the encapsulation of the object's data.

The risk that comes with the latter form (your code is now tied to the current version of Whatever::Module, and that requirement is neither enforced nor documented) just doesn't seem worth the gain of avoiding creating $content.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://368184]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found