in reply to Slicing a string on words
You just gotta believe! If faith is not enough, then may I suggest you post the contents of your $vars?$window_start = 5; $window_size = 5; $text_body = "Please ignore all this text, this is the text wanted, pl +ease none of this text"; if ($window_start > 0) { $text_body =~ /\S+/g foreach 1..$window_start; $start_index = pos($text_body); } else { $start_index = 0; } $text_body =~ /\S+/g foreach 1..$window_size; $end_index = pos($text_body); $windowed_text = substr($text_body, $start_index, ($end_index - $start +_index)); print $windowed_text; #prints " this is the text wanted,"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Slicing a string on words
by dstar (Scribe) on Aug 28, 2001 at 02:47 UTC | |
by dga (Hermit) on Aug 28, 2001 at 03:37 UTC |