<mordy> you can’t <alnewkirk> 0- -0 <mordy> there might be some module which abstracts this for you <mordy> but it’s 2-3 lines and there’s no nice way to circumvent it. while hashes and arrays might ‘seem’ similar they’re quite different <mordy> one nasty way: * jjore assumes it’d be good for vreg to figure out how to do this. <mordy> yes it would <mordy> hrrm.. bold <mordy> also, don’t forget about scalar references and globs <alnewkirk> v-reggie, define “child objects” <mordy> and code references <vreg> and FORMAT and IO and LVALUE and <uri> vreg: those aren’t objects. they are glob slots <vreg> ah <vreg> okah * jjore figures it’d be good to start with two types: just non-references like “foo” and arrays. Then figure out how to do hashes. Then scalar references. Then, etc. The principles are the same but it’s increasing the difficulty. <alnewkirk> I just wrote something up on “vague requirements” <mst> vreg: where did you find out about those from? <vreg> mst: http://perldoc.perl.org/functions/ref.html <mst> vreg: ok, those are things that a reference can be taken to <mst> vreg: a JSON structure can only contain scalars, arrays and hashes <mst> vreg: so if you’re still on the same exercise ARRAY and HASH are the only ones you need to care about <vreg> am i incorrect in thinking if $value doesn’t refer to (point to?) a hash or array it is considered a scalar? <mordy> in your specific usecase, yes <mst> vreg: $value is always a scalar. in this case, it is a scalar containing a reference to something. <mordy> err.. i mean you’re not incorrect <mst> vreg: but, in terms of JSON, if it isn’t a reference to a hash or array then it’ll be a scalar. <vreg> if it’s bottomed out does that mean <vreg> ah * vreg cheers up a bit. <mst> vreg: well, actually, there’s one other case <vreg> can i just test for if $value->{…} is a scalar? <mst> vreg: JSON has a boolean type, which will be returned as a JSON::XS::Boolean object or something <mordy> vreg: your recursion function is iterative. the ‘bottoming-out’ is inherent. what you need to worry about is dereferencing something that’s not a reference <mst> vreg: but those print out just fine, so meh <vreg> and that would indicate it’s not pointing to an array or hash? <mst> vreg: here’s what I’d write. <mst> vreg: my $ref = ref($thing); if ($ref eq ‘HASH’) {
<dhoss> i wanna learn C better Session Close: Sun Feb 12 00:00:01 2012
Feb 152012