[Top][All Lists]

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

Re: (no subject)

From: Tim Van Holder
Subject: Re: (no subject)
Date: Mon, 17 Sep 2001 22:08:01 +0200

> I'd prefer that you change XFile's open to handle this.  Would that be
> a problem?

My feeble perl knowledge suggests this should do the trick:

sub open
  my ($fh) = shift;
  my ($file) = @_;

  # WARNING: Gross hack: $FH is a typeglob: use its hash slot to store
  # the `name' of the file we are opening.  See the example with
  # io_socket_timeout in IO::Socket for more, and read Graham's
  # comment in IO::Handle.
  ${*$fh}{'autom4te_xfile_file'} = "$file";

  if (!$fh->SUPER::open (@_))
      my $me = basename ($0);
      my $file = ${*$fh}{'autom4te_xfile_file'};
      croak "$me: cannot open $file: $!\n";
  binmode $fh->SUPER
    if ${*$fh}{'autom4te_xfile_file'} =~ /^\s*>\s*[^-]/;

The "\s*[^-]" is there to ensure we don't put stdout in binary mode.

(Note: is $file invalidated after the SUPER::open? If not, then why is
${*$fh}{'autom4te_xfile_file'} used in the error handler?)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]