Relative Content

Tag Archive for perlarrayref

Can perl automaticly delete a scalar and replace with arrayref?

This is a self contained example of a hard to find bug I tracked down.
A module call it ‘A’ has a function to flatten its data structure that is mostly strings
that has to do with hiding data in a html form.
Along with the strings it occasionally unintentionally flattened an arrayref and also hid it in the form.
it made it round trip and the array showed up as a string ‘array’ => ‘ARRAY(0x55abf15aa790)’
when the function gen_array that generates the arrayref runs again to recreate the arrayref it
cannot re-initialize the scalar as an arrayref with @{ $self->{arrayref} } = (), if its already a string.
why is that?
From perldoc perldata: