in reply to Re: Re: Chomp(<handle>)
in thread Chomp(<handle>)

$ perl -e 'chomp(" foo ");' Can't modify constant item in chomp at - line 1, near "" foo ")"
$ perl -e 'chomp(<STDIN>);' Can't modify <HANDLE> in chomp at - line 1, near "<STDIN>)"
Different error messages. In the first case, it complains about modifying a non-lvalue (a constant item). In the second case, it complains about modifying the results of reading from a file handle.

I'll grant you that chomp SCALAR can't chomp a non-lvalue, if you'll grant that the ambiguous context of the syntax chomp <FOO> is another valid reason that the compiler gives a separate distinct message.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^4: Chomp(<handle>)
by dws (Chancellor) on Jul 14, 2003 at 19:23 UTC
    In the second case, it complains about modifying the results of reading from a file handle.

    Care to place a small wager on that? I could be wrong. You might make a buck.

Re: Re^3: Chomp(<handle>)
by edan (Curate) on Jul 15, 2003 at 11:31 UTC

    I disagree. They are the same error message:

    Can't modify %s in %s

    (see perldoc perldiag, search for modify)

    chomp can only modify an lvalue, and neither a 'constant item' nor '<filehandle>' are lvalues, just as dws said.

    --
    3dan