RE: Why is this a problem?

2005-07-01 Thread Thomas, Mark - BLS CTR
Hugh Loebner wrote: > foreach my $fhkey ( keys %fh){ > open ( $fh{$fhkey}, ">$fhkey" ) ; > } Nobody mentioned this yet: Since you want your filehandles to be unique, why not use the key of the hash instead of the value? In other words, change the above to: foreach my $fhkey ( keys %fh){

RE: Why is this a problem?

2005-07-01 Thread Jim Guion
Because the first parameter passed to open is the file handle.  In the first case, there are 3 file handles: 1,2,3.  In the second case, the same file handle is used for each file, always ‘1’.   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hugh Loebner Sent: Fri

Re: Why is this a problem?

2005-07-01 Thread $Bill Luebkert
Hugh Loebner wrote: > Hello perl gurus, > > I spent almost a whole day solving this problem. However, I wonder why > it's a problem. > # > # The following program (which is what I started out with) will NOT work > properly: Each eleme

Re: Why is this a problem?

2005-07-01 Thread Chris Wagner
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},

RE: Why is this a problem?

2005-07-01 Thread Gardner, Sam
Title: Message See answers: my    %fh = ( aa => 1, bb =>2, cc => 3) ;  # note that each instance of $fh{$fhkey} has a different valueforeach my $fhkey ( keys %fh){    open  ( $fh{$fhkey}, ">$fhkey" )  ;## >so, you open 3 file handles, one named "1", one named "2", and one named "3"