in reply to Re: reverse is not reversing
in thread reverse is not reversing

oh. it only works with more than one word. i thought it would reverse "apple" into "elppa".

Replies are listed 'Best First'.
Re^3: reverse is not reversing
by choroba (Cardinal) on Nov 26, 2018 at 15:21 UTC
    No, it will reverse "apple" into "elppa", but only in scalar context. Read more about context in the book Modern Perl.

    Update: Fixed the book title. Thanx LanX.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      > in the book Moder Perl

      Molder Perl? ;-p

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re^3: reverse is not reversing
by LanX (Saint) on Nov 26, 2018 at 15:21 UTC
    > it only works with more than one word

    that's wrong, context matters (LHS) not input (RHS)

    DB<9> print reverse "text" # list context text DB<10> print scalar reverse "text" # scalar context txet DB<11> $a= reverse "text" # scalar DB<12> print $a # still print LIST, but $a is +already reversed txet

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice