in reply to Re^2: Adjusting variable context when working with JSON data?
in thread Adjusting variable context when workign with JSON data?

  I find this syntax a bit strange: (@$decoded)

That's something you will have to get used to as it's a fundamental syntax in perl. $decoded is a reference to an array. To dereference it you just put a @ at the front. e.g. $x = [1,2,3]; @array = @$x. You can also put squiggles around the reference if that makes it clearer and in some cases this is needed, like @{$decoded}.

Replies are listed 'Best First'.
Re^4: Adjusting variable context when working with JSON data?
by unmatched (Sexton) on Dec 08, 2024 at 10:52 UTC
    I thought that you "\" to de-reference, or maybe that's just for hashes? But in any case I think you're right, I need to write some more Perl to get used to this. I've only started to pick it up out of curiosity, and so far I've only written a few things here and there to get a taste of the basics. Thanks for the help!

      Preceding with a backslash creates a reference to the operand. De-referencing is the opposite of this. Do have a read of the intro to references tutorial, perlreftut and perlref for getting started with references.


      🦛

        Oh, I see. I got it completely backwards. For some reason I thought that `$` was used only for scalar values. Will read more on this, thanks again!