Subject: | mmap on new hash or array entry |
Date: | Fri, 16 Apr 2010 09:11:50 +1000 |
To: | bug-File-Map [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
File::Map 0.24 on debian i386 on
use File::Map 'map_file';
my %hash;
map_file ($hash{'foo'}, '/etc/motd', '<');
print $hash{'foo'};
gets an error
Can't upgrade LVALUE (10) to 8 at /usr/lib/perl5/File/Map.pm line 77.
In 0.23 something happened that instantiated and set the hash entry.
Perhaps it was the effect of the prototype.
I'm not certain if a non-existent hash entry is a sensible thing to pass
in. Perhaps it's correct as-now to reject all lvalue (and magical
maybe) scalar inputs.
But if making a hash or array entry spring in existence was possible it
could be a cute though, saving a dummy creation first,
$array[123] = undef;
map_file ($array[123], '/etc/motd', '<');
If that's what has to be done, for now at least, it might be worth
showing somewhere near the end of the docs ...