method interpolation

Uri Guttman uri at
Wed Feb 1 16:27:30 GMT 2006

>>>>> "PM" == Paul Makepeace < at> writes:

  PM> Je 2006-02-01 13:24:38 +0000, Iain Tatch skribis:
  >> On 01/02/06, Dirk Koopman <djk at> wrote:
  >> > My brain is failing me. Is there some incantation (probably including
  >> > {}) that allows one to do something like:
  >> >
  >> > print "This is $syiq->UNIQID";
  >> warn "Ugly code follows:";
  >> print "This is ${\( $syiq->UNIQID )}\n";

  PM> The "canonical" way which is basically the same but with a list
  PM> context is,

  PM>   print "This is @{[ $sys->UNIQ_ID ]}";

actually they are both in list context. this is a known bug (or
undocumented feature) and has been known for a good long while.


sub context {

	return wantarray ? 'LIST' : 'SCALAR' ;

print "array is @{[context()]} context\n" ;
print "scalar is ${\context()} context\n" ;

array is LIST context
scalar is LIST context

same output for all of these:

This is perl, v5.8.6 built for sun4-solaris
This is perl, v5.6.1 built for sun4-solaris
This is perl, version 5.004_04 built for sun4-solaris


Uri Guttman  ------  uri at  --------
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------

More information about the mailing list