Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hplabs!hpl-opus!hpnmdla!darrylo From: darrylo@hpnmdla.HP.COM (Darryl Okahata) Newsgroups: comp.lang.perl Subject: Bug in perl3pl44? Message-ID: <8310020@hpnmdla.HP.COM> Date: 1 Feb 91 19:23:12 GMT Organization: HP Network Measurements Div, Santa Rosa, CA Lines: 41 In perl 3 pl 44, Can a filehandle be passed by reference be opened in a subroutine and be passed back to the caller? I have a subroutine that opens a filehandle passed by reference and passes it back to the caller. However, when I use the filehandle in the caller, it's as if the filehandle was never opened. Here's a short example: ------------------------------------------------------------------------------- #! /usr/bin/perl # # This perl script should create a file called "foofile" in the current # directory, and the file should contain a couple lines of text. # However, it doesn't. # $file = "foofile"; &open_file(*output, $file); print output "foo1\n"; print output "foo2\n"; close(output); exit 1; ############################################################################### sub open_file { local(*output2, $file) = @_; open(output2, ">$file") || die "Can't open $file"; } ------------------------------------------------------------------------------- Am I doing something stupid, or is this a bug? I'm running perl on an HP375 running HP-UX 7.0. -- Darryl Okahata UUCP: {hplabs!, hpcea!, hpfcla!} hpnmd!darrylo Internet: darrylo%hpnmd@hp-sde.sde.hp.com