[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#214036: im: imput doesn't work with Perl 5.8.1



On Tue, Oct 21, 2003 at 01:13:49AM +0900, Tatsuya Kinoshita wrote:

> With the perl 5.8.1 package, the line input operator (<>) causes
> "Bad file descriptor".  This problem is reproducible by the
> following sample code.
> 
> ---- 
> #!/usr/bin/perl
> $file = "/etc/debian_version";
> open(FH, $file) or die "Cannot open $file";
> $! = 0;
> $line = <FH>;
> if ($!) {
>     print "System error: $!\n";
> }
> print "$line\n";
> close(FH);
> ---- 
> 
> Is this a bug in the perl 5.8.1 pakcage?  Or a Perl's feature?
> What should I do?

  The following change makes the code work as expected:

    @line = <FH>;
    print @line . "\n";

  skx@undecided:~$ cat t.pl
  #!/usr/bin/perl -w
  use strict;
  my $file = "/etc/debian_version";
  open(FH, "<".$file) or die "Cannot open $file - $!";
  #$! = 0;
  my @line = <FH>;
  if ($!) {
      print "System error: $!\n";
  } 
  print "@line\n";
  close(FH);

Steve
--
# Debian Security Audit Project
http://www.steve.org.uk/Debian/



Reply to: