Skip Menu |

This queue is for tickets about the Config-File CPAN distribution.

Report information
The Basics
Id: 33753
Status: resolved
Worked: 20 min
Priority: 0/
Queue: Config-File

People
Owner: GWOLF [...] cpan.org
Requestors: swp5jhu02 [...] sneakemail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 1.4
  • 1.41
Fixed in: (no value)



Subject: File handle $fh needs closing after file handle has been read...
Date: Sun, 02 Mar 2008 18:19:21 +0100
To: bug-Config-File [...] rt.cpan.org
From: Peter Valdemar Mørch <swp5jhu02 [...] sneakemail.com>
Inserting this line: $fh->close(); after the while() loop closes the file after reading. Reproducing the bug: Open a particular config file with read_config_file() on windows using wperl.exe (not perl.exe!) from strawberry perl. Try to open the config file with gvim on windows, while the perl process is still running. It will open in read-only mode, because another process is accessing the file (the wperl.exe process from before). If I insert the $fh->close() above, the config file opens in r/w mode, as I would have expected. I'm wondering why the $fh is not closed when it goes out of scope, but from experimenting I can see that it does make a difference whether the explicit $fh->close() is there or not. (So maybe the garbage collector does close the file in due course, but that isn't fast enough. read_config_file() leaves the config file open in the mean time.) Workaround: my $configFile = 'c:/my.conf'; open my $configHandle, '<', $configFile or die "Couldn't open $configFile"; my $configContents = join('', <$configHandle>); close $configHandle; # You can open a filehandle to a reference to a scalar. # See perldoc -f open my $config = read_config_file( \$configContents ); bla bla bla Peter -- Peter Valdemar Mørch http://www.morch.com
From: GWOLF [...] cpan.org
I just uploaded 1.42 fixing the bug you spot. Strange. I hope you don't mind, I'll be filing the bug on IO::File - http://rt.cpan.org//Ticket/Display.html?id=33799 I'm closing this bug on Config::File - Feel free to open it if you think it's not resolved.