in reply to Re: Recursively substitute against multidimensional hash
in thread Recursively substitute against multidimensional hash

Thanks for that but can I ask a hypothetical question? If the hash I was using was not %var but $self-{'VAR'} where $self is a blessed object reference and the original code which had been edited for clarity actually looked like
$work =~ s{%(\w+)(?:\.(\w+))?}{ defined $2 ? $self->{'VARS'}{$1}{$2} : $self->{'VARS'}{default}{$1} }eg;
How would one call your dive function in this hypothetical case? Because I've tried
my $fml = $self->{'VARS'}; $work =~ s{ % ( \w+ (?:\.\w+)* ) }{ dive($fml, split /\./, $1) }xegr;
and even $fml = \%{$self->{'VARS'}}; but not substitution is happening despite cut'n'pasting from your example code which is working fine in another windowd. NGL this is a humiliating way to stumble at the finish line yet here I am.

Replies are listed 'Best First'.
Re^3: Recursively substitute against multidimensional hash
by Maelstrom (Beadle) on Feb 14, 2025 at 18:32 UTC
    Nevermind it wasn't the reference it was that sneaky little /r at the end of the regexp that was changing my functions behaviour.
      Nevermind it wasn't the reference it was that sneaky little /r at the end of the regexp that was changing my functions behaviour.

      Note I would have never been able to guess that from the code you showed, which is why a Short, Self-Contained, Correct Example is so important, like I showed in my reply above.