[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: [ID 20000119.007] truncate() does not work on iorefs or globrefs
On Wed, 19 Jan 2000 12:24:40 EST, David Huggins-Daines wrote:
>This code:
>
>#!/usr/bin/perl
>sub foo {
> local *I;
> open I, ">bar" or die $!;
> print I "quux";
> return *I{IO}
>}
>
>$i = foo;
>seek $i,0,0 or die "seek: $!";
>truncate $i,0 or die "trunc: $!"
>__END__
>
>Gives this output:
>
>dhd@blood-axp:~$ perl footest
>trunc: No such file or directory at footest line 11.
>
>If I change *I{IO} to \*I, it still does not work.
>If I change *I{IO} to *I, then it does work.
>
>I imagine someone has already reported this problem...
Unfortunately, *I{IO} and \*I never quite really worked for many of the
filehandle operators. The documentation is rather misleading on this
score; patches welcome.
In 5.6, you'll be able to autovivify and pass around anonymous filehandles
much more readily, like so:
sub foo {
open my $I, ">bar" or die $!;
print $I "quux";
return $I;
}
Note that all file/socket/dir handle constructors will support that,
not just open().
Sarathy
gsar@ActiveState.com
- References to:
-
David Huggins-Daines <dhd@eradicator.org>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]