Skip Menu |

This queue is for tickets about the YAML-Syck CPAN distribution.

Report information
The Basics
Id: 59432
Status: resolved
Priority: 0/
Queue: YAML-Syck

People
Owner: TODDR [...] cpan.org
Requestors: TODDR [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.10
Fixed in: 1.10_01



Subject: Should use lexical file handles.
Now YAML::Syck uses lexical file handles, We should do this in the modules: s/FH/my $fh/g;
Done and added to github
Subject: patch.txt
commit a23cff43203a7130bc2f99ddf256e39c4f444cfe Author: Todd Rinaldo <toddr@cpan.org> Date: Thu Jul 15 21:48:49 2010 -0500 RT 59432 - use lexical file handles for read/write to files diff --git a/lib/JSON/Syck.pm b/lib/JSON/Syck.pm index 13afda2..f564a5e 100644 --- a/lib/JSON/Syck.pm +++ b/lib/JSON/Syck.pm @@ -18,10 +18,9 @@ sub DumpFile { print {$file} YAML::Syck::DumpJSON($_[0]); } else { - local *FH; - open(FH, '>', $file) or die "Cannot write to $file: $!"; - print FH YAML::Syck::DumpJSON($_[0]); - close FH; + open(my $fh, '>', $file) or die "Cannot write to $file: $!"; + print $fh YAML::Syck::DumpJSON($_[0]); + close $fh; } } @@ -35,9 +34,8 @@ sub LoadFile { YAML::Syck::LoadJSON(do { local $/; <$file> }); } else { - local *FH; - open(FH, '<', $file) or die "Cannot read from $file: $!"; - YAML::Syck::LoadJSON(do { local $/; <FH> }); + open(my $fh, '<', $file) or die "Cannot read from $file: $!"; + YAML::Syck::LoadJSON(do { local $/; <$fh> }); } } diff --git a/lib/YAML/Syck.pm b/lib/YAML/Syck.pm index a6e6327..541e33d 100644 --- a/lib/YAML/Syck.pm +++ b/lib/YAML/Syck.pm @@ -104,15 +104,14 @@ sub DumpFile { } } else { - local *FH; - open(FH, '>', $file) or die "Cannot write to $file: $!"; + open(my $fh, '>', $file) or die "Cannot write to $file: $!"; if ($#_) { - print FH YAML::Syck::DumpYAML($_) for @_; + print $fh YAML::Syck::DumpYAML($_) for @_; } else { - print FH YAML::Syck::DumpYAML($_[0]); + print $fh YAML::Syck::DumpYAML($_[0]); } - close FH; + close $fh; } } @@ -125,9 +124,8 @@ sub LoadFile { Load(do { local $/; <$file> }); } else { - local *FH; - open(FH, '<', $file) or die "Cannot read from $file: $!"; - Load(do { local $/; <FH> }); + open(my $fh, '<', $file) or die "Cannot read from $file: $!"; + Load(do { local $/; <$fh> }); } }