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.
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 92
Now YAML::Syck uses lexical file handles, We should do this in the modules: s/FH/my $fh/g;
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1279248577-2366-53"
Message-ID: <rt-3.8.HEAD-2366-1279248577-1809.59432-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 24
Done and added to github
MIME-Version: 1.0
Subject: patch.txt
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/plain; charset="utf-8"; name="patch.txt"
Content-Disposition: inline; filename="patch.txt"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 2126
Download patch.txt
text/plain 2k
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> }); } }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.