Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: (Ovid) Re(2): ref, no, maybe?

by Fastolfe (Vicar)
on Jan 11, 2001 at 04:40 UTC ( [id://51040] : note . print w/replies, xml ) Need Help??


in reply to (Ovid) Re(2): ref, no, maybe?
in thread ref, no, maybe?

For what it's worth, in my opinion, your use of ref here is perfectly valid and makes your function very flexible and easy to use, for the uses you have for it.

I remember something in a project I was involved in in the distant past that made use of data structures a little like this:

$struct = { key => { sub_key => 'value', sub_key2 => 'value2', }, key2 => 'other_value', };
Or maybe it was:
@items = ( 'item1', [ 'nested1', 'nested2', 'nested3' ], [ 'nested4', [ 'nested5', 'nested5a' ] ], 'item6', 'item7', [ 'nested8', 'nested9' ], );
I don't fully remember the rationale for building a data structure like that, but I think it had something to do with decision-making, where if you'd come across a reference, only one of the references would be used, with control passing off to the next item when it was completed (something like that). I just remember that it required us to use 'ref' when processing it, and perhaps a bit of recursion. I'm perfectly willing to accept that this is bad practice, and I've learned a lot of Perl between then and now and it's likely that I might have come up with alternative way to accomplish what we were doing... *shrug*.