in reply to element of an array of arrays

splice( my @Records );

I think you have used this personal idiom before, and I even seem to remember a discussion about it in some other thread.

This is very puzzling to me. Can you say or provide a link back to a previous statement of why you prefer this particular idiom?

I know that some authorities advocate the occasional use of a statement like
    my $scalar = undef;
or
    my @array = ();
as a way of obviating the need for a comment to the effect
    # this thing really needs to be (undefined|empty) for when it is used later in the script
(of course, by default scalars are undefined and arrays empty upon creation). However, the use of splice in this context, if that is the intent, seems likely to produce only a blank stare in a future reader/maintainer (who may even be yourself!), followed by a scramble to the docs to find the effect on an array of  splice when used with no other parameters.

Yours in confoositude?

Replies are listed 'Best First'.
Re^2: element of an array of arrays
by LanX (Saint) on Jun 17, 2013 at 14:43 UTC
    AnomalousMonk++

    But since it has no effect to empty a freshly declared array in such a complicated way, I'd rather classify it as cargo cult (sorry) nonsense or even try-and-error coding. =)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      I'd rather classify it as cargo cult nonsense.

      And I'd be so inclined myself except that I can't remember ever seeing this particular usage in any other code from which JockoHelios might have cargo cult-ed it into his or her own; it seems to be an utterly unique creation.

Re^2: element of an array of arrays
by JockoHelios (Scribe) on Jun 17, 2013 at 14:53 UTC
    Earlier on (a couple of weeks, at least) after starting to use strict, I'd tried to declare arrays and had gotten error messages. To get past that, I'd started declaring arrays using splice. It always struck me as odd, but since it worked I continued to do it that way.

    I didn't think of the simple declaration syntax that hdb mentioned above. I thought I had to actually do something with an array when declaring it. That's the reason I've been declaring arrays using splice, which of course I can discontinue :)

    Dyslexics Untie !!!
      ... I'd tried to declare arrays and had gotten error messages. To get past that, I'd started declaring arrays using splice. ... since it worked I continued to do it that way.

      This strikes me as a perfect example of the Skinnerian process of shaping "superstitious" behavior.

      Please do not take this the wrong way: I do not mean it to be in any way offensive or a personal attack. If Skinner's analysis is right, "superstitious behavior" of this kind is something we all exhibit, know it or not, and always have and always will as long as we remain organisms whose behavior is predominantly operant. However, with self-awareness, we can occasionally eliminate behaviors that are wasteful of time or effort, or are actively destructive — and so you have!

      Look at Perl like a powerful tool which can do much good but also cause much destruction.

      It's no good for try and error hacking!!!

      Better get a good book and try to understand step by step what you are doing!

      Please don't try pressing every possible button to get only seemingly correct results...

      Cheers Rolf

      ( addicted to the Perl Programming Language)