A good way to get to know splice better is to re-implement push, pop, unshift and shift with it.
Uhm, or you could just read the docs :-)
A good way to get to know substr better is to create push/pop/unshift/shift functions for strings.
D:\Development>perldoc -f splice
The following equivalences hold (assuming "$[ == 0"):
$a[$x] = $y splice(@a,$x,1,$y)
Well.... Once you know how to implement splice using susbtr you dont need to implement push/pop/unshift or shift, but its true it might be a good exercise.
Personally would suggest taking that thought a step further and reimplement Tie::CharArray, by the time you are done if you dont understand Tie's, Array implementation, Splice Implementation and Substr implementation then I would say theres something very wrong... (either with the individual or the code ;-) Oh and it probably is a good idea because you can use the CPAN module for a proper code comparison and review afterward.
Thats what I did to learn Tie the first time anyway... :-)
Yves / DeMerphq
Writing a good benchmark isnt as easy as it might look.
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>
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
Want more info? How to link or
or How to display code and escape characters
are good places to start.