You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dump() incorrectly treats $. as undef. Here is a quick example :
use strict;
use warnings;
use YAML::Syck;
my @lines;
open my $fh, "<", $0 or die $!;
while (<$fh>) {
push @lines, {bad_num => $., good_num => $.+0, line => $_};
}
print Dump(\@lines);
__END__
Output :
---
-
bad_num: ~
good_num: '1'
line: "use strict;\n"
-
bad_num: ~
good_num: '2'
line: "use warnings;\n"
<etc.>
Hi,
On Fri Jul 19 23:06:22 2013, DAMI wrote:
> Dump() incorrectly treats $. as undef. Here is a quick example :
>
> use strict;
> use warnings;
> use YAML::Syck;
>
> my @lines;
> open my $fh, "<", $0 or die $!;
> while (<$fh>) {
> push @lines, {bad_num => $., good_num => $.+0, line => $_};
> }
>
> print Dump(\@lines);
>
> __END__
> Output :
> ---
> -
> bad_num: ~
> good_num: '1'
> line: "use strict;\n"
> -
> bad_num: ~
> good_num: '2'
> line: "use warnings;\n"
> <etc.>
I can't see an easy way to make that work safely. The parameters to Dump are passed down to the XS function XS_YAML__Syck_DumpYAML and the C code doesn't know about special Perl variables. Example $$ doesn't work either.
By adding 0 for good_num, Perl is evaluating that before it becomes an argument for Dump, and so that on works.
Gordon
The text was updated successfully, but these errors were encountered:
Migrated from rt.cpan.org#87084 (status was 'open')
Requestors:
From [email protected] on 2013-07-20 03:06:22:
From [email protected] on 2016-02-05 04:11:21:
The text was updated successfully, but these errors were encountered: