Try this (untested):
#The variable $fh is not a filehandlie - you need to assign that:

my $fh = "somefile";

open (FILE, ">$fh test") || die $!;  # Open file for writing
while (<FILE>) {
   print FILE "Hello\n";
}
close (FILE);

Some would say you don't need to do the close.  Some say you do.  I usually do
explicitly, to be consistant.



At 16:10:24, on 07.10.03:
Cracks in my tinfoil beanie allowed Jamie Risk to seep these bits into my brain:,
> I'm a casual PERL programmer at best, and I have a working facsimile of the
> non-working code below.  When I run it, I get an error "print() on closed
> filehandle $fh at ./test.pl line [n]".
> 
> This is just my first step to being able to pass file handles to my
> sub-routines.  What have I missed?
> 
> open my $fh, "test" || die $!;
> print $fh "Hello!\n";
> close $fh;
> 
> Secondly, how do I pass STDOUT has a file handle to a sub-routine?
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
                  o      _     _         _
          _o     /\_   _ \\o  (_)\__/o  (_)
        _< \_   _>(_) (_)/<_    \_| \   _|/' \/
       (_)>(_) (_)        (_)   (_)    (_)'  _\o_
               http://zapatopi.net/afdb.html







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to