Help for this page

Select Code to Download


  1. or download this
    my $str="hello there bob smith and more words";
    my $num_words=5;
    if (my ($words) = $str=~ /((?:\w+(?:\W+|$)){$num_words})/) {
     print $words;
    }
    
  2. or download this
    @words = split /\W+/, $words;