At 09:20 AM 7/1/05 -0400, [EMAIL PROTECTED] wrote:
># this works fine, produces three files, aa , bb, cc with contents 'xxx aa 
>xxx' etc
>
>my %fh = ( aa => 1, bb =>2, cc => 3) ; # note that each instance of 
>$fh{$fhkey} has a different value
>
>foreach my $fhkey ( keys %fh){
>open ( $fh{$fhkey}, ">$fhkey" ) ; 
>}

In this case, ur successively opening three file handles, with the values,
1, 2, and 3.  If you want the file handle to be the name of the key, it
should be $fhkey not $fh{$fhkey}.

># The following program (which is what I started out with) will NOT work 
>properly: Each element of %fh has a value of 1
># Why doesn't this work properly? - all statements write to one file
>my %fh = ( aa => 1, bb =>1, cc => 1) ; # note - only change, each $fh{} has 
>value of 1
>foreach my $fhkey ( keys %fh){
>open ( $fh{$fhkey}, ">$fhkey" ) ; 
>}

Here ur opening the same file handle, 1, three times.








--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede males"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to