in reply to Re^2: I've been bit in the neck by open()
in thread I've been bit in the neck by open()

sub unique { my %seen; $seen{$_}++ for @_; keys %seen; } my @unique_values = unique( @some_values );

While it's not the best or most efficient way, it is the standard way to extract the unique elements from an array. Do you really want N "uninitialized variable" warnings where N is the number of unique elements in your array?

And, that's just one common usage.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^4: I've been bit in the neck by open()
by RazorbladeBidet (Friar) on Feb 16, 2005 at 13:32 UTC
    To be honest, yes, if I've requested warnings.

    But this is probably just a philosophical divide. I often get mixed feelings about languages that require initialization versus assumptions. One day I like one, the other day I like another :-D

    I assume there's some measure of consistency, though. I guess what I'm really wondering is - where is that line?
      I assume there's some measure of consistency, though. I guess what I'm really wondering is -where is that line?

      Where Larry told it to be. :-) (Plus, consistency is the hobgoblin of foolish minds, or something like that.)

      I'm not being facetious - this is just one of those nooks and crannies of Perl5 that you either know or you don't. Perl6 (supposedly) will be more consistent, but Perl5 isn't. *shrugs*

      Or, rather, it's very consistent, for some definition of consistent. (Probably not the Webster's definition, though ... remember - it's not messy, it's in a state of creative flux!)

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        A foolish consistency is the hobgoblin of little minds

        Close, but a little different, order of operations is important! :) I would assume that in a programming language that kind of consistency would not be foolish, but then again, two weeks ago I would have said PERL.

        Ok, but I'll take your word for it - trial by fire! Thanks for the info
Re^4: I've been bit in the neck by open()
by blazar (Canon) on Feb 16, 2005 at 14:42 UTC
    While it's not the best or most efficient way, it is the standard way to extract the unique elements from an array. Do you really want N "uninitialized variable" warnings where N is the number of unique elements in your array?

    And, that's just one common usage.

    I know you're not answering to me, but to another monk. However that "that's just one common usage" thing seems to me to be a reminiscence of my original post, in which case I'd like to point out that I've noticed it's been misunderstood, well at least about that cmt about a warning, that is. I already posted a reply in which I hopefully explain better what I really meant...