in reply to Re: How do I reverse the order of the first and last word of a string?
in thread How do I reverse the order of the first and last word of a string?

and doing without the join:

my $string = 'This is my program'; my @arr = split ' ', $string; print "@arr[-1, 1..$#arr-1, 0]";

After all, we don't want to introduce too much on the first lesson.


DWIM is Perl's answer to Gödel
  • Comment on Re^2: How do I reverse the order of the first and last word of a string?
  • Download Code

Replies are listed 'Best First'.
Re^3: How do I reverse the order of the first and last word of a string?
by Zaxo (Archbishop) on Mar 11, 2007 at 06:50 UTC

    I think I added the similar code while you were writing that. In any case, join is probably easier to teach than $", the array interpolation seperator.

    After Compline,
    Zaxo

      .oO(Damn, now where did I put that tounge in cheek symbol?)


      DWIM is Perl's answer to Gödel