Created
February 5, 2014 22:16
-
-
Save dagolden/8834407 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use YAML::Tiny; | |
####### | |
# Make an object from "data": | |
my $data = "000 000"; | |
my $hash1 = {split /\s/, $data}; | |
print Dump $hash1; # expect '000': '000' (Works) | |
# Attempt to force numeric | |
$hash1->{'000'} += 0; | |
print Dump $hash1; # expect '000': 0 (Works) | |
####### | |
# User created object: | |
my $hash2 = { 000 => 0 }; | |
# NOTE: This implies all Perl numeric keys dumped should be quoted. | |
print Dump $hash2; # expect '0': 0 (Works) | |
# Attempt force to string: | |
$hash2->{0} = $hash2->{0} . ""; # (Works) | |
# my $hash2->{0} .= ""; # (Doesn't Work) Dumps: '0': '' | |
# my $hash2->{0} = "$hash2->{0}"; # (Works) | |
print Dump $hash2; # expect '0': '0' (Works) | |
$hash2->{0} = 42; | |
print Dump $hash2; # expect '0': 42 (Works) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment