Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: HTML::Template Interpolation Error?

by hbo (Monk)
on Aug 16, 2004 at 21:26 UTC ( #383466=note: print w/ replies, xml ) Need Help??


in reply to Re: HTML::Template Interpolation Error?
in thread HTML::Template Interpolation Error?

Bingo, I think!

So, why does ''.checkbox_group(.. flatten the list? Is

"some string".('a','list','of','strings');
equivilant to
"some string".'a'.'list'.'of'.'strings';
?

"Even if you are on the right track, you'll get run over if you just sit there." - Will Rogers


Comment on Re^2: HTML::Template Interpolation Error?
Select or Download Code
Re^3: HTML::Template Interpolation Error?
by blokhead (Monsignor) on Aug 16, 2004 at 21:35 UTC
    No, it's because the author of CGI.pm wrote it to do so:
    sub checkbox_group { ... return wantarray ? @elements : join(' ',@elements) ... }
    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.

    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

      Got it.

      So the  ''.checkbox_group(... construct imposed scalar context, which returned something HTML::Template::param() could deal with.

      Thanks for the education!

      "Even if you are on the right track, you'll get run over if you just sit there." - Will Rogers

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2015-07-03 03:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls