develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: RFC 237 (v1) hashes should interpolate in double-quoted strings

Thread Next
From:
Chaim Frenkel
Date:
September 17, 2000 20:54
Subject:
Re: RFC 237 (v1) hashes should interpolate in double-quoted strings
Message ID:
m3g0mye4o2.fsf@csamnycln01.nyc.csam.com
>>>>> "PRL" == Perl6 RFC Librarian <perl6-rfc@perl.org> writes:

PRL> =head1 ABSTRACT

PRL> "%hash" should expand to:

PRL>   join( $/, map { qq($_$"$hash{$_}) } keys %hash )

PRL> =head1 DESCRIPTION

PRL> Hashes do not interpolate in double-quote context in perl5.  They 
PRL> should, because (a) scalars and arrays do, (b) it is a useful
PRL> thing.

PRL> The big problem is that % is heavily used in double-quoted strings 
PRL> with printf.  I don't have a solution to this.  In the end, this may 
PRL> be B<the> definitive reason why hashes do not interpolate.  And that's 
PRL> fine by me.

What about formating the output as a value that can be used by eval?

	%hash = (a => 1, b => 'the world');
	print "%{hash}\n";

('a' => 1, 'b'=> 'the world')

And as for having to escape % in printf strings. Why not enable the
interpolation if the %{ is seen?

<chaim>
-- 
Chaim Frenkel					     Nonlinear Knowledge, Inc.
chaimf@pobox.com				               +1-718-236-0183

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