in reply to Substring consisting of all the characters until "character X"?
What is so complicated/annoying about the code above? If you don't like it, merge lines 4 and 5 into one line - or move them to a sub... HTH, Ratamy $str = "ABXCDEFDGXTGRAAAAAA"; my $start = 5; my $char = "X"; my $end = index($str, $char, $start); my $result = substr($str, $start, $end-$start); print $result, "\n";
|
|---|