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