develooper Front page | perl.perl6.language | Postings from April 2001

Lvaluability

Thread Next
From:
Simon Cozens
Date:
April 27, 2001 23:09
Subject:
Lvaluability
Message ID:
20010428031108.A29172@netthink.co.uk
substr($foo, 1, 3) = "hi!"; # We all know this.
splice(@foo, 1, 3) = @bar;  # But the lack of this seems asymmetric

$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 { ... }

$#array = 10;               # We can currently change an array's length
length($scalar) = 10;       # But not this?

-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

# Oh, why stop there?
/../g  = sub { ... }        # Calls the sub 3 times, replacing each pair of
                            # characters with the return value.

-- 
The course of true anything never does run smooth.
		-- Samuel Butler

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About