Aaron Sherman wrote:
> On Sat, 2002-09-07 at 14:22, Smylers wrote:
>
> > Should that C<+> be there? I would expect chomp only to remove a
> > single line-break.
>
> Note that this is in paragraph (e.g. C<$/=''>) mode....
Ah, yes. I quoted the wrong case above. The final branch deals with
the case when C<$/> (or equivalent) is set:
} else {
$string =~ s/<{"<[$irs]>"}>+$//;
return $0;
}
If C<$irs = "\n"> then I'd only expect a single trailing newline to be
removed but that substitution still looks as though it'll get rid of as
many as are there.
> > In a scalar context does C<reverse> still a string with characters
> > reversed?
>
> Yes, but that would be:
>
> sub reverse($string) {
> return join '', reverse([split //, $string]);
> }
Perl 5's C<reverse> is sensitive to the context in which it is called
rather than the number of arguments. This is an 'element' reversal with
only one element:
$ perl -wle 'print reverse qw<abc>'
This is a 'character' reversal even though several strings have been
passed:
$ perl -wle 'print scalar reverse qw<abc def>'
So a C<reverse> with a single array parameter could be either type.
Smylers