in reply to find the starting character position in a line
I recommend reviewing your course notes. You can approach the problem using index, Regular Expressions, or with the following code:
$line = " This is the test line"; $* = 'line'; # prepare Perl for treating 'line' @${*} = grep { !m!\s! } split //, reverse (''.$${*}); shift @{$*} while @{$*} > $[ +1; print $line[-1], " is the first character.\n";
|
|---|