Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truncate() does not work on iorefs or globrefs #1055

Closed
p5pRT opened this issue Jan 19, 2000 · 3 comments
Closed

truncate() does not work on iorefs or globrefs #1055

p5pRT opened this issue Jan 19, 2000 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 19, 2000

Migrated from rt.perl.org#2006 (status was 'resolved')

Searchable as RT2006$

@p5pRT
Copy link
Author

p5pRT commented Jan 19, 2000

From dhd@eradicator.org

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...

Perl Info


Site configuration information for perl 5.00503:

Configured by chris at Mon Dec 20 08:37:50 EST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.14pre9, archname=alpha-linux
    uname='linux spawn 2.2.14pre9 #2 wed dec 15 00:24:37 est 1999 alpha unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.95.2 19991109 (Debian GNU/Linux)
    cppflags='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=8, ptrsize=8, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/lib/perl5/5.005/alpha-linux
    /usr/lib/perl5/5.005
    /usr/local/lib/site_perl/alpha-linux
    /usr/local/lib/site_perl
    /usr/lib/perl5
    .


Environment for perl 5.00503:
    HOME=/home/dhd
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jan 20, 2000

From @gsar

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

@p5pRT
Copy link
Author

p5pRT commented Jan 20, 2000

From [Unknown Contact. See original ticket]

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.

I certainly have tried to fix that before. Of course, my idea
of fixing it is to deprevaricate the docs. :-)

--tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant