in reply to Re: Creating flexible method accessor
in thread Creating flexible method accessor
Thanks for the help!
Couple of responses/questions:
1. I actually do use strict & warnings at the top of all of my scripts.
2. I actually had a typo in my copying over my routines. I didn't use 'for my $_ (@_)', rather I used 'for (@_)' and then used '$_' to reference the current iterated array element which I thought was always ok. At least it doesn't give me errors in 5.10.0
. 3. I like your way of not using eval.
4. However, I wanted to be able to pass something more general than just 'data'. For example. I might want to access several layers down as in: $self->{data}->{level2}->{level3}' etc. More generally, I would like to pass an arbitrary 'path' to some sequence of hashes and arrays to get/set to the desired accessor element. (btw I am using this to access elements of a JSON-decoded string which typically can be multiple levels deep)
Couple of responses/questions:
1. I actually do use strict & warnings at the top of all of my scripts.
2. I actually had a typo in my copying over my routines. I didn't use 'for my $_ (@_)', rather I used 'for (@_)' and then used '$_' to reference the current iterated array element which I thought was always ok. At least it doesn't give me errors in 5.10.0
. 3. I like your way of not using eval.
4. However, I wanted to be able to pass something more general than just 'data'. For example. I might want to access several layers down as in: $self->{data}->{level2}->{level3}' etc. More generally, I would like to pass an arbitrary 'path' to some sequence of hashes and arrays to get/set to the desired accessor element. (btw I am using this to access elements of a JSON-decoded string which typically can be multiple levels deep)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Creating flexible method accessor
by puterboy (Scribe) on Feb 02, 2014 at 02:53 UTC | |
by puterboy (Scribe) on Feb 02, 2014 at 03:04 UTC | |
by Anonymous Monk on Feb 02, 2014 at 03:50 UTC | |
by puterboy (Scribe) on Feb 02, 2014 at 04:08 UTC | |
by Anonymous Monk on Feb 02, 2014 at 04:20 UTC | |
Re^3: Creating flexible method accessor
by Anonymous Monk on Feb 02, 2014 at 04:14 UTC |
In Section
Seekers of Perl Wisdom