Help for this page

Select Code to Download


  1. or download this
    my $str = "some string\n\n\n\n";
    chomp $str;
    print "[$str]";    # still three trailing newlines
    ...
    $/ = "";           # 'paragraph mode'
    chomp $str;
    print "[$str]";    # all gone
    
  2. or download this
    $/ = 'ggl';             # giggle mode
    my $str2 = "a string ggl";
    my $cnt = chomp $str2;
    print "$cnt";           # prints: 3