I've had occasions where $bar->{url_target} is actually a deeply nested data structure (thank you XML), so:
$bar->{fu}{man}{chu}{with}{a}{lemon}{twist} ? do_something_wise($bar->{fu}{man}{chu}{with}{a}{lemon}{twist}) : or_not($bar->{fu}{man}{chu}{with}{a}{lemon}{twist}) is pretty painful. On those occasions I've done: ($_ = $bar->{fu}{man}{chu}{with}{a}{lemon}{twist}) ? do_something_wise($_) : or_not($_) It's a little more obtuse, but you'r not a likely to fat-finger the reference. The downside is any possible side affects of using "$_". On 7/31/06, Ben. B. <[EMAIL PROTECTED]> wrote: > I haven't been following along too closely so I'm not sure if this > will help but I've had luck with doing things similar to the > following: > > <% $bar->{url_target} and qq{target="$bar->{url_target}"} %> > > I'm not sure if this will work in your situation however. > > -b > > On 7/31/06, Eric Harrison <[EMAIL PROTECTED]> wrote: > > Due to the fact that the substitution block is pulled out of your code with > > a sweet RegExp and then passed to $m->print(), there's really nothing you > > can do to achieve your exact request. The closest thing I could come up with > > ( and I hope you appreciate this because it took me about 2 hours of > > rummaging through Lexer.pm and Compiler.pm and Interp.pm before finally > > figuring out this solution ) is this: > > > > <% eval { qq{target="$bar->{url_target}"} if $bar->{url_target} } %> > > > > Which works. If you'll go take a look in your masondata folder at the file > > that contains that code after it's compiled, you'll see: > > > > $m->print ( eval { qq{target="$bar->{url_target}"} if $bar->{url_target} } > > ); > > > > That does work. Not quite what you're looking for and even more verbose than > > my beloved tertiary operator, but you had inspired my curiosity regarding > > why the substitution block was so limited in it's accepted syntax. I had > > always just assumed that it was some kind of nonsensical eval error, but > > after looking at the mason-compiled object file and seeing that it's just > > passing the whole sting into $m->print(), I understand completely. > > > > Why is it that you don't like the cute tertiary syntax? I love the > > question-mark/colon syntax. I think it looks really nice in certain places > > in the code. It gives you the syntactical power to make conditional > > statements very easy to read through. What and why do you have a grudge > > against it? > > > > Hope I was able to help. Let me know if anything else breaks... :D > > > > -Eric > > http://pirate-js.sourceforge.net > > > > > > On 7/31/06, Mason List <[EMAIL PROTECTED]> wrote: > > > I'd like to be able to avoid writing code like this: > > > <% $bar->{url_target} qq{target="$bar->{url_target}"} : '' %> > > > and instead: > > > <% qq{target="$bar->{url_target}"} if $bar->{url_target} %> > > > > > > though as I write this email I see I'm not saving much typing... > > > > > > Anyway, what do people do? > > > > > > > > ------------------------------------------------------------------------- > > > Take Surveys. Earn Cash. Influence the Future of IT > > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > your > > > opinions on IT & business topics through brief surveys -- and earn cash > > > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > _______________________________________________ > > > Mason-users mailing list > > > Mason-users@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/mason-users > > > > > > > > > > > -- > > erh > > http://ericnix.org > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share your > > opinions on IT & business topics through brief surveys -- and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > > _______________________________________________ > > Mason-users mailing list > > Mason-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/mason-users > > > > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Mason-users mailing list > Mason-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mason-users > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users