in reply to Why doesn't Perl warn me about this bareword? (IO::Prompt prompt -line)

It's like the prefix equivalent of the fat arrow. Unary string minus.

From perlop:

Unary "-" performs arithmetic negation if the operand is numeric. If the operand is an identifier, a string con- sisting of a minus sign concatenated with the identifier is returned.
  • Comment on Re: Why doesn't Perl warn me about this bareword? (IO::Prompt prompt -line)
  • Download Code

Replies are listed 'Best First'.
Re^2: Why doesn't Perl warn me about this bareword? (IO::Prompt prompt -line)
by j3 (Friar) on Nov 15, 2006 at 20:24 UTC

    Whoops! Thanks fishbot_v2. I don't know why my brain thought that minus sign was part of the identifier.

    Neat feature/trick. Makes function calls look somewhat like running shell commands.

      Well, the string returned by -word does include the -, so it's an easy mistake to make.

      >perl -e "print -word -word

      Aside, I prefer
      prompt -line => "Eh?: ";
      over
      prompt -line, "Eh?: ";
      since the two form a name-value relation.

      Update: Oops, I thought -line and "Eh?: " were related.

        Aside, I prefer
        prompt -line => "Eh?: ";
        over
        prompt -line, "Eh?: ";
        since the two form a name-value relation.

        Actually, according to the IO::Prompt docs (the ascii-table in the INTERFACE section), -line doesn't actually take an argument, and so looks to me like it doesn't actually have a name-value relationship with the prompt string.