http://qs321.pair.com?node_id=438525


in reply to Re: Should chomping a constant always raise an error?
in thread Should chomping a constant always raise an error?

sub modify { chomp( $_[0] ); # whatever else happens, you've just potentially modified $_[0] } modify('fred'); # What would you expect to happen to 'fred'?
Great example. For those who did not try it out, it causes a runtime exception:
Modification of a read-only value attempted at /tmp/t.pl line 2.
Can modify somehow be declared to only take a modifiable parameter, so that we can have a compile-time error (as happens with the core chomp)?
Can't modify constant item in modify at -e line 1, at end of line Execution of -e aborted due to compilation errors.