in reply to Re: Filehandle in hash value gets lost
in thread Filehandle in hash value gets lost

:P sorry about that... actually it was stupid and I solved it myself five minutes after posting (I already said in a post that I'm an idiot...).

Actually, I needed to:
foreach (@files) { $_->{fh}->close; }
and that basically took care of it, but it looks pretty ugly to me. But then again, I am just learning perl (my resident guru says I still "speak perl with a C accent"). ...sigh... Well, at least I'm trying!

Replies are listed 'Best First'.
Re^3: Filehandle in hash value gets lost
by Ionizor (Pilgrim) on Dec 20, 2002 at 02:51 UTC

    To make it look more pretty try:

    foreach my $file (@files) { $file->{fh}->close(); }

    Update: Changed close to close() to improve readability.

      Is that "better code" too? (stylistically, etc)

        "better code"... *shrug* Maybe. Maybe not. It doesn't rely on $_ to be there which is important in more complicated code where you might affect the value of $_ without realising... I also find it easier to read personally.

      To make it look more pretty...
      This is a matter of taste, and the basis of many flame wars.
      In short, if that's how he likes his code, let him do it.
      I for one like it his way.
      Changed close to close() to improve readability.
      And I suppose you'd change print; to print(); to improve readability?
      Anyway, close takes no arguments. I like to leave out unnecessary parens whenever possible, and I'm guessing other people do too.

      jdporter
      ...porque es dificil estar guapo y blanco.

        In short, if that's how he likes his code, let him do it. I for one like it his way.

        I only posted because he mentioned that it looked ugly to him:

        but it looks pretty ugly to me.

        And I suppose you'd change print; to print(); to improve readability? Anyway, close takes no arguments. I like to leave out unnecessary parens whenever possible, and I'm guessing other people do too.

        Okay, I find this comment to be bordering on flamebait - of course I wouldn't change print; to print();. I changed close to close() because it's object oriented style and it makes it blindingly obvious even at a glance that close() is a method and not a variable reference. Some people like to leave out unnecessary parens wherever possible. Some don't. I don't think it's fair to criticise what I've written at the same time you're telling me that I should let every person code how they like to code.

Re: Re: Re: Filehandle in hash value gets lost
by batkins (Chaplain) on Dec 20, 2002 at 02:50 UTC
    ah, it's all good.