in reply to Re^2: HTML::Template Interpolation Error?
in thread HTML::Template Interpolation Error?
A list in scalar context (as in your example directly above) returns the last element of the list (your expression evaluates to "some stringstrings"). For a function, if you want different behavior (as in checkbox_group), you check for scalar or list context with wantarray and return the appropriate thing manually.sub checkbox_group { ... return wantarray ? @elements : join(' ',@elements) ... }
The CGI docs could probably do a better job making this obvious, though. Perhaps there's a blanket statement somewhere about all HTML-generation functions having this behavior in scalar context?
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: HTML::Template Interpolation Error?
by hbo (Monk) on Aug 16, 2004 at 21:48 UTC |