in reply to .. in reverse

I wonder about the comparative efficiency of @A[reverse3 .. 50] and reverse @A[3 .. 50]?


Well It's better than the Abottoire, but Yorkshire!

Replies are listed 'Best First'.
Re: Re: .. in reverse
by blakem (Monsignor) on Aug 31, 2002 at 01:17 UTC
    Of course they aren't always interchangable.... One can be used as an lvalue the other can't.
    #!/usr/bin/perl -wT use strict; my @a = 'a'..'f'; @a[reverse 5..10] = 'A'..'F'; # can you rewrite this line? print "@a\n"; __END__ a b c d e F E D C B A

    -Blake

      Yes! But It's not as pretty.

      #!/usr/bin/perl -w use strict; my @a = 'a'..'f'; #@a[reverse 5..10] = 'A'..'F'; # can you rewrite this line? splice @a, 5, 10-5, reverse ('A'..'F'); print "@a\n"; __END__ C:\test>194289.pl a b c d e F E D C B A

      Well It's better than the Abottoire, but Yorkshire!
      @a[reverse 5..10] = 'A'..'F';  # can you rewrite this line?
      @a[5..10] = reverse 'A'..'F';

      Not that it really addresses the point...

      -sauoq
      "My two cents aren't worth a dime.";