A tied scalar shadows an object whose class provides methods for creation, assignment and destruction. The tied scalar behaves like a scalar, so you can neither bless it into a package, nor call methods on it (would need to be blessed, first).
You are pretty out of luck if you want to use the same thingy as a scalar and an object at the same time. Your FETCH would need to know what the fetch is for - not just void/scalar/list context, but look ahead in the opstack to see whether the result it is about to return is for a method deref. I'm sure that can be done somehow (TheDamian, would you like to? ;-), but it probably would involve too much magic...
Use the object returned by tie to do method calls:
use Link;
my $var_o = tie my $var,"Link","http://somesite.com";
$var = "http://anothersite.com";
$var_o->print_method;
print $var;
Or what Arunbear said.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|