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

I've been tracking down a problem in the following code:
my(%conscols2)=%{pop(@_)}; open(FILEHANDLE,">>filename"); select(FILEHANDLE); @cons_block=keys(%conscols2);
The problem is that with the select in the code the array @cons_block ends up with nothing in it. If I remove the select line all is well and @cons_block contains the keys for %conscols2. Any wisdom on why this is happening would be greatly appreciated

Replies are listed 'Best First'.
Re: FileHandle Select Problem?
by danboo (Beadle) on Apr 16, 2002 at 15:51 UTC
    My guess would be that your doing:
    print @cons_block;
    and not seeing anything since it's actually doing:
    print FILEHANDLE @cons_block;
    Remember that print defaults to STDOUT because it is the default selected filehandle. To get around this, be specific:
    print STDOUT @cons_block;
    If it's not the case, perhaps you can share more of the code you use to test the data in @cons_block.

    - danboo

      Stupid..Stupid...Stupid... That was it. Thanks a lot danboo!