in reply to Re: Re: Proper way to print a large number of strings
in thread Proper way to print a large number of strings

use CGI; $cgi = new CGI; print << "HEREDOC"; $cgi->p("Test.") HEREDOC
I get CGI=HASH(0x119960)->p("Test.")

What you want to do is take a reference to your object, and interpolate it via a scalar reference. Look at the following:

$cgi->p('test') | V \$cgi->p('test') | V ${\$cgi->p('test')}

In Perl 6, ${...} becomes a mere scalar, and no longer a scalar reference, so you'll be able to write ${$cgi->p('test')} which will be pretty cool. Until then, you'll have to make do with using the above hack. Sometimes this is acceptable, sometimes it's better to do something like:

print 'stuff ' . $q->b( $q->i( 'and' )) . ' nonsense'

It all depends on what comes out as being more readable.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

Replies are listed 'Best First'.
Re^4: Proper way to print a large number of strings (use scalar interpolation)
by Aristotle (Chancellor) on Jan 11, 2003 at 16:39 UTC
    Or the IMHO more tolerable @{[ $cgi->p('test') ]} which avoids the ugly backslash and creates a sort of (unwieldy) "template directive look&feel" with its paired delimiters.

    Makeshifts last the longest.