in reply to New user, confusion over print and lists

When you specify $_ as an argument for reverse in list context, it is taken as the single member of the list to reverse. Equivalently, no arguments represent an empty list.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: New user, confusion over print and lists

Replies are listed 'Best First'.
Re^2: New user, confusion over print and lists
by jktstance (Novice) on Jan 23, 2014 at 18:26 UTC
    OK, I understand why the string is being printed back as is (1-length list). I'm still confused on why the behavior is different when I explicitly state $_ and when I do not.

    When reverse has no arguments, doesn't it just take $_? Is writing reverse; the same as reverse $_;? I'm imagining this to be the behavior, because print; and print $_; seem identical when I test them.

    EDIT: From the doc, I seems that reverse will ONLY work on $_ if it is in scalar context, which print is not. So I give it no arguments in list context, does reverse ignore $_, which the doc seems to imply it does. If so, is it just returning an empty list which is then passed to print?