Wojtek.Pilorz
2006-Dec-12 08:34 UTC
[CentOS] perl on CentOS 4.4 : PERLIO=perlio vs stdio, readline error handling
I sometimes use an example from readline entry in perlfunc(1). This used to work for me, but know (after I upgraded to CentOS) works only if PERLIO=stdio is defined in environment. See the following: [xx at xx testreadline]$ cat testreadline.pl #!/usr/bin/perl use warnings; use strict; for my $fn (@ARGV) { local (*F); open F, "< $fn" or die "open err for fn=$fn: $!"; binmode(F); my $c = 0; local $/=\8192; local $_; for (;;) { undef $!; unless (defined($_ = <F>)) { die $! if $!; last; }; $c += length $_; } close(F) or die "close err fn=$fn: $!"; print "fn=$fn, byte count=$c;\n"; } [xx at xx testreadline]$ env LANG=C perl testreadline.pl testreadline.pl Bad file descriptor at testreadline.pl line 14, <F> chunk 1. [xx at xx testreadline]$ env LANG=C PERLIO=perlio perl testreadline.pl testreadline.pl Bad file descriptor at testreadline.pl line 14, <F> chunk 1. [xx at xx testreadline]$ env LANG=C PERLIO=stdio perl testreadline.pl testreadline.pl fn=testreadline.pl, byte count=390; Is the method of checking for errors with readline described in perlfunc(1) no longer good? Any hints would be most welcome. Best regards, Wojtek BTW. Perl installed is as follows: [xx at xx testreadline]$ rpm -qi perl Name : perl Relocations: (not relocatable) Version : 5.8.5 Vendor: CentOS Release : 36.RHEL4 Build Date: Sun 13 Aug 2006 12:25:48 AM CEST Install Date: Fri 15 Sep 2006 10:42:26 AM CEST Build Host: build-i386 Group : Development/Languages Source RPM: perl-5.8.5-36.RHEL4.src.rpm Size : 32713959 License: Artistic or GPL Signature : DSA/SHA1, Sun 13 Aug 2006 02:56:06 PM CEST, Key ID a53d0bab443e1821 Packager : Johnny Hughes <johnny at centos.org> URL : http://www.perl.org/ Summary : The Perl programming language.