Help for this page

Select Code to Download


  1. or download this
    my $sentence = 'Sam goes to school to play football.';
    
    substr($sentence, $_, 0) = '**' for 35, 27, 18, 12;
    
    print $sentence, "\n";
    
  2. or download this
    $sentence =~ s/(school)/**\1**/;
    
  3. or download this
    my $sentence = 'Sam goes to school to play football.';
    
    # Count the spaces and add 1
    my $count1 = substr($sentence, 0, 12) =~ y/ // + 1;