Subject: | anchors and aliases: dereferencing scalars |
YAML loses the relation between anchor and alias when converting to
perl. YAML::Syck and YAML::XS do it right, preserving a reference.
% cat anchor_and_alias_03.yml
---
hr:
- Mark McGwire
# Following node labeled SS
- &SS Sammy Sosa
rbi:
- *SS # Subsequent occurrence
- Ken Griffey
% ysh -MYAML < anchor_and_alias_03.yml
$VAR1 = {
'hr' => [
'Mark McGwire',
'Sammy Sosa'
],
'rbi' => [
'Sammy Sosa',
'Ken Griffey'
]
};
% ysh -MYAML::XS < anchor_and_alias_03.yml
$VAR1 = {
'hr' => [
'Mark McGwire',
'Sammy Sosa'
],
'rbi' => [
${\$VAR1->{'hr'}[1]},
'Ken Griffey'
]
};
% ysh -MYAML::Syck < anchor_and_alias_03.yml
$VAR1 = {
'hr' => [
'Mark McGwire',
'Sammy Sosa'
],
'rbi' => [
${\$VAR1->{'hr'}[1]},
'Ken Griffey'
]
};