You're not putting an object in the hash, so you can't
call a method on it later. What you're actually
doing is calling a class method on the package that
corresponds to whatever pack() returns.
The first form works because you are re-blessing the packed
version into the class that contains the unpack_name()
method. I'm not sure why the second form works at all
without resulting in an error, actually.
There are modules on the CPAN that will let you tie()
a hash to a database and then store and fetch references
(including blessed ones) from them, or you could roll
your own with Storable or FreezeThaw or the like.
-
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.
|