8 use vars qw($VERSION $AUTOLOAD);
11 use Scalar::Util qw(blessed);
16 my ( $self, $tied ) = @_;
17 my ( $method ) = ( $AUTOLOAD =~ /([^:]+)$/ );
19 if ( $method =~ /^TIE/ ) {
20 if ( blessed($tied) ) {
23 croak "You must supply an object as the argument to tie()";
26 croak "Unsupported method for $method, this module is only for tying to existing objects";
38 Tie::ToObject - Tie to an existing object.
44 my $stolen = tied(%something);
46 tie %something_else, 'Tie::ToObject', $stolen;
50 While L<perldoc/tie> allows tying to an arbitrary object, the class in question
51 must support this in it's implementation of C<TIEHASH>, C<TIEARRAY> or
54 This class provides a very tie constructor that simply returns the object it
55 was given as it's first argument.
57 This way side effects of calling C<< $object->TIEHASH >> are avoided.
59 This is used in L<Data::Visitor> in order to tie a variable to an already
60 existing object. This is also useful for cloning, when you want to clone the
61 internal state object instead of going through the tie interface for that
64 =head1 VERSION CONTROL
66 This module is maintained using Darcs. You can get the latest version from
67 L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
72 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
76 Copyright (c) 2008 Yuval Kogman. All rights reserved
77 This program is free software; you can redistribute
78 it and/or modify it under the same terms as Perl itself.