@@ -17,12 +17,13 @@ my @KEYS;
17
17
sub to_toml {
18
18
my $data = shift ;
19
19
die ' toml: data to encode must be a hashref' if ref $data ne ' HASH' ;
20
- return _to_toml( $data );
20
+ return _to_toml( $data , { @_ } );
21
21
}
22
22
23
- sub _to_toml {
23
+ sub _to_toml ($$);
24
+ sub _to_toml ($$) {
24
25
my $data = shift ;
25
- my $param = ref ( $_ [1]) eq ' HASH ' ? $_ [1] : undef ;
26
+ my $param = shift ;
26
27
27
28
die ' toml: found undefined value, which is unsupported by TOML' if ! defined $data ;
28
29
@@ -82,6 +83,7 @@ sub _to_toml {
82
83
return ' nan' if Math::BigFloat-> new($data )-> is_nan;
83
84
return $data ;
84
85
}
86
+ return to_toml_string($data ) if $param -> {no_string_guessing };
85
87
# return $data if svref_2object(\$data)->FLAGS & (SVf_IOK | SVf_NOK);
86
88
return $data if $data =~ / ^$DateTime $ / ;
87
89
return lc ($data ) if $data =~ / ^$SpecialFloat $ / ;
@@ -103,7 +105,7 @@ sub to_toml_inline_table {
103
105
if (ref $val eq ' HASH' ) {
104
106
push @buff , $key . ' =' . to_toml_inline_table($val );
105
107
} else {
106
- push @buff , $key . ' =' . _to_toml($val );
108
+ push @buff , $key . ' =' . _to_toml($val , $param );
107
109
}
108
110
}
109
111
@@ -144,7 +146,7 @@ sub to_toml_table {
144
146
145
147
for (@{ $data -> {$k } }) {
146
148
push @buff_tables , ' ' , ' [[' . join (' .' , map { to_toml_key($_ ) } @KEYS ) . ' ]]' ;
147
- push @buff_tables , _to_toml($_ );
149
+ push @buff_tables , _to_toml($_ , $param );
148
150
}
149
151
150
152
pop @KEYS ;
0 commit comments