From 047c4f33756612ef7efae41cb4efca52f800787a Mon Sep 17 00:00:00 2001 From: Elvin Aslanov Date: Tue, 30 Aug 2022 11:32:25 +0400 Subject: [PATCH] [doc] Update FileHandle synopsis Add `my` to examples for better practice. --- lib/FileHandle.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/FileHandle.pm b/lib/FileHandle.pm index c9d5f40999..a4ae1e437c 100644 --- a/lib/FileHandle.pm +++ b/lib/FileHandle.pm @@ -4,7 +4,7 @@ use 5.006; use strict; our($VERSION, @ISA, @EXPORT, @EXPORT_OK); -$VERSION = "2.04"; +$VERSION = "2.05"; require IO::File; @ISA = qw(IO::File); @@ -111,36 +111,36 @@ FileHandle - supply object methods for filehandles use FileHandle; - $fh = FileHandle->new; + my $fh = FileHandle->new; if ($fh->open("< file")) { print <$fh>; $fh->close; } - $fh = FileHandle->new("> FOO"); + my $fh = FileHandle->new("> FOO"); if (defined $fh) { print $fh "bar\n"; $fh->close; } - $fh = FileHandle->new("file", "r"); + my $fh = FileHandle->new("file", "r"); if (defined $fh) { print <$fh>; undef $fh; # automatically closes the file } - $fh = FileHandle->new("file", O_WRONLY|O_APPEND); + my $fh = FileHandle->new("file", O_WRONLY|O_APPEND); if (defined $fh) { print $fh "corge\n"; undef $fh; # automatically closes the file } - $pos = $fh->getpos; + my $pos = $fh->getpos; $fh->setpos($pos); - $fh->setvbuf($buffer_var, _IOLBF, 1024); + $fh->setvbuf(my $buffer_var, _IOLBF, 1024); - ($readfh, $writefh) = FileHandle::pipe; + my ($readfh, $writefh) = FileHandle::pipe; autoflush STDOUT 1;