Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i'm new in perl but I have to open n file and associate the name with a filehandle so after I can write in this file I try to use typeglob to save a "reference" to filehandle I give to my file a name like FDn with n = 0,1,... and I'd like to save a reference into an hash so from my filename I can get the right filehandle but... how I write: $FileDescriptor{$fd} = *FD$n this doesn't work Can sameone help me? Thanks Jojoz

Replies are listed 'Best First'.
Re: filehandle
by chromatic (Archbishop) on Mar 25, 2000 at 05:04 UTC
    The interpreter is a little confused -- it's not picking up "> foo" as arguments for the $fh->open method call. Wrap it in parenthesis to make it all clear: if ($fh->open("> foo")) { Works for me!
RE: filehandle
by Anonymous Monk on Mar 26, 2000 at 08:08 UTC
    use FileHandle; $fh = new FileHandle; if ($fh->open ("> foo")) { print $fh "bar\n"; $fh->close; } # Try this - there were just a couple of missing brackets