Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
    print "Output 1:",$str1,"\n"; ## this removes the spaces after 1
    print "Output 2:",$str1,"\n"; ## does nothing
    print "Output 3:",$str1.$str2,"\n"; ## removes spaces and concatenates
    
  2. or download this
    Output 1:The tailing spaces example 1
    Output 2:The tailing spaces example 2
    Output 3:The tailing spaces example 1The tailing spaces example 2
    
  3. or download this
    $str1 =~ s/\s+//g;
    
  4. or download this
    Output 1:Thetailingspacesexample1
    Output 2:Thetailingspacesexample2
    Output 3:Thetailingspacesexample1Thetailingspacesexample2