Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Interpolation via return ..END...

by Rudif (Hermit)
on Aug 24, 2001 at 02:41 UTC ( #107524=note: print w/replies, xml ) Need Help??


in reply to Interpolation via return ..END...

So, you want to interpolate a result of a method call, right?

Here is one way to do it

#!perl -w use strict; use Number::Format; sub HTML_SomethingBetter { my $t = shift; my $d = new Number::Format (-thousands_sep => ',', -decimal_point =>' +.', -decimal_fill => 2); return <<END; <tr/td code> @{[$d->format_number($t->{key})]} </tr> END } print "<-- SomethingBetter -->\n"; print HTML_SomethingBetter { key => ' 3.1415956 ' }; __END__ <-- SomethingBetter --> <tr/td code> 3.14 </tr>
See also Effective Perl Programming item 58, where it is described as U.B.E.: Ugly But Effective.

My mnemonic for  @{[...]} is "All Embracing Bracketts"

Cheers
Rudif

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://107524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2023-12-11 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?