On Sat, 2002-09-07 at 14:22, Smylers wrote:
> Aaron Sherman wrote:

> > sub chomp($string is rw){
[...]
> >             } elsif $irs.length == 0 {
> >                     $string =~ s/ \n+ $ //;
> 
> 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....

> > sub reverse(@list) {
> >     my @r;
> >     my $last = @list.length - 1;
> >     for(my $i=$last;$i >= 0;$i++) {
> >             @r[$last-$i] = @list[$i];
> >     }
> >     return *@r;
> > }
> 
> 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]);
    }

Though this example is too inefficient, it does demonstrate the point.

-- 
Aaron Sherman <[EMAIL PROTECTED]>
http://www.ajs.com/~ajs

Reply via email to