pg has asked for the wisdom of the Perl Monks concerning the following question:

Wondering whether anyone else has already experienced this problem. This piece of code worked fine with 5.8.2 (I just retested, and is fine):

my $credentials = chomp(encode_base64("peip:930612"));

But it does not work with 5.8.4, and complains: "Can't modify non-lvalue subroutine call in chomp"...

Replies are listed 'Best First'.
Re: Can't modify non-lvalue subroutine call in chomp
by davido (Cardinal) on Jul 19, 2004 at 21:13 UTC

    Is it your intention to assign the length of whatever gets chomped (usually '\n') to $credentials? chomp's return value is the length of whatever got chomped, not the input-string minus the chomped bit.

    chomp acts upon its parameter list, and in your case, is trying to modify the non-lvalue sub.

    Update: chomp returns length of chomped portion, not the chomped portion itself.

    Dave

Re: Can't modify non-lvalue subroutine call in chomp
by VSarkiss (Monsignor) on Jul 19, 2004 at 21:17 UTC

    What you want is to chomp the scalar, not the return value: chomp(my $credentials = encode_base64("peip:930612")); As usual, this is untested, etc.

Re: Can't modify non-lvalue subroutine call in chomp
by ccn (Vicar) on Jul 19, 2004 at 21:17 UTC

    I wonder how it can work. chomp returns number of deleted characters. Do you really want to $credentials have this numeric value?