Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Rindex used to find end of a string
February 28, 2007, 5:34 pm
rate this thread
Re: Rindex used to find end of a string
Not easily. For a task like this you want a regex. The index of the last
non-whitespace character in a string $str can be found with
$str =~ /(\s*)$/ && length($str) - length($1) - 1;
...but if you just want to remove it you'd be better off doing that in
$str =~ s/\s*$//;
You need to read up on basic Perl operations: I would recommend you get
a good book.
Raise your hand if you're invulnerable.
- » Hash of arrays of hashes... There's got to be a cleaner way than this...
- — Previous thread in » PERL Discussions