http://qs1969.pair.com?node_id=145827


in reply to call sub in string

I've used this with heredocs in CGI scripts. Example:
#!/usr/bin/perl sub top_html { return "<html><head>$_[0]</head><body>"; } print <<EOF; @{[top_html("catchy title")]} blah.. EOF

Explanation:
@{ somearef } takes an array reference "somearef" and dereferences it.
[ somearray ] takes a list "somelist" and makes an array ref of it.
@{ [ function() ] } takes the list returned by "function()" and wraps it in a way that is interpolatable by quotemarks.