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


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

Personally, it makes a lot of sense. Sure if there's no need to chomp a value then it shouldn't hurt. However the function *must* be assuming the input it to be modifyied in some way otherwise you'd not pass a value to it that you expect to be modified.
sub modify { chomp( $_[0] ); # whatever else happens, you've just potentially modified $_[0] } modify('fred'); # What would you expect to happen to 'fred'? my $f ="fred\n"; modify($f); print $f; #fred
sub modify2 { # Create a copy of the input my $input = $_[0]; chomp($input); } modify('fred'); # works now because we're not modifying the input, but a copy of it. my $f ="fred\n"; modify($f); print $f; #fred\n

Cheers!
Rick
If this is a root node: Before responding, please ensure your clue bit is set.
If this is a reply: This is a discussion group, not a helpdesk ... If the discussion happens to answer a question you've asked, that's incidental.