in reply to call sub in string
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2: call sub in string
by tilly (Archbishop) on Feb 16, 2002 at 16:21 UTC |