use strict; use warnings; sub unchomp { my @data = @_; foreach my $string ( @data ) { $string .= "\n" unless $string =~ m/\n$/; } return @data; } print unchomp( "a\n", "b", "c" )