programming-examples/perl/String/Chomp the pre-set character.pl

13 lines
267 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl
my $string1 = "This is a string";
print "\$string1 is \"$string1\"";
print "\n\nChanging \$/ to \"g\" \n\n";
$/ = "g";
# Removing last character if it is equal to "g"
chomp ( $string1 );
print "The new \$string1 is \"$string1\"\n";