On Sat, Apr 28, 2001 at 03:11:08AM +0100, Simon Cozens wrote:
> substr($foo, 1, 3) = "hi!"; # We all know this.
> splice(@foo, 1, 3) = @bar; # But the lack of this seems asymmetric
An originally we had
splice(@foo, 1, 3, @bar);
but not
substr($foo, 1, 3, "hi!");
which are more useful, IMO, as they return what was replaced. Where
the assignment version returns what was assigned.
> $baz = $foo.bar; # Surely this is just overloaded "." being a
> # subroutine in $foo's package called with a
> # bareword --- $foo->concat("bar")
>
> $foo.bar = $baz; # sub concat :lvalue { ... }
I will leave those :)
> $#array = 10; # We can currently change an array's length
> length($scalar) = 10; # But not this?
and we have keys(%hash) = 10 to set the number of buckets in the hash
> -s $filename = 0; # calls trunc()
> -M $filename = 0; # calls utime()
>
> #(And now, over to Abigail...)
> $_ = "foobar";
> /foo/ = "baz"; # Now $_ = "bazbar"
> /ba./g = <one two>; # Now $_ = "onetwo", using Larry's new <> qw
I don't remember seeing anything about <> as qw, can you give me a reference
> # Oh, why stop there?
> /../g = sub { ... } # Calls the sub 3 times, replacing each pair of
> # characters with the return value.
I was going to respond to the lines above with "do we need another way to do s///"
but this one would probably make it an advantage. Or is this the same as s/../foo()/ge
?
Graham.