Help for this page

Select Code to Download


  1. or download this
    my $suffix;
    $suffix = 'st' if ($nouser =~ /1$/);
    ...
    $suffix = 'rd' if ($nouser =~ /3$/);
    $suffix = 'th' if ($nouser =~ /(?:4|5|6|7|8|9|0)$/);
    $suffix = 'th' if ($nouser =~ /(?:11|12|13)$/);
    
  2. or download this
    my $suffix;
    if    ($nouser =~ /(?<!1)1$/) { $suffix = 'st'; }
    elsif ($nouser =~ /(?<!1)2$/) { $suffix = 'nd'; }
    elsif ($nouser =~ /(?<!1)3$/) { $suffix = 'rd'; }
    else                          { $suffix = 'th'; }
    
  3. or download this
    my $suffix;
    local *_ = \$nouser;
    ...
    elsif (/(?<!1)2$/) { $suffix = 'nd'; }
    elsif (/(?<!1)3$/) { $suffix = 'rd'; }
    else               { $suffix = 'th'; }
    
  4. or download this
    my $suffix;
    foreach ($nouser) {
    ...
       elsif (/(?<!1)3$/) { $suffix = 'rd'; }
       else               { $suffix = 'th'; }
    }
    
  5. or download this
    my $suffix;
    foreach ($nouser) {
    ...
    
       $suffix = 'th';
    }