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

To make it look more pretty try:

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

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

Replies are listed 'Best First'.
Cool! Thanks!
by mr. jaggers (Sexton) on Dec 20, 2002 at 02:53 UTC
    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.

Re: Re(3): Filehandle in hash value gets lost
by jdporter (Paladin) on Dec 20, 2002 at 14:08 UTC
    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.