in reply to Reading session data

G'day Peter,

From "Re^2: Reading session data":

"Old syntax :D Must be getting old."

Newer syntax:

$ perl -E ' use v5.36; use YAML::XS; my $yaml = Load(<<~\EOY); oauth: azuread: login_info: roles: - Medewerkers - etm EOY my $session_data = $yaml->{oauth}; say for $session_data->{azuread}{login_info}{roles}->@*; ' Medewerkers etm

— Ken

Replies are listed 'Best First'.
Re^2: Reading session data
by PeterKaagman (Beadle) on Jul 02, 2023 at 11:10 UTC

    Correct me if I'm wrong, but using a YAML lib would only work whenever I use YAML for my sessions. Which is not good practice in a production env as I understand. The session should be agnostic to the format in which it is stored.

      Your example data used YAML; I used an appropriate module to get that data into a Perl data structure.

      My point, however, was not about YAML; it was in relation to old and new syntax.

      hippo had already shown how to get a single array element:

      $session_data->{azuread}{login_info}{roles}[0]

      I showed a newer syntax for getting the entire array:

      $session_data->{azuread}{login_info}{roles}->@*

      Your post resulted in further discussion of old/new syntax. It was an interesting conversation; so, thanks for that.

      — Ken