-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin Old wrote:
> I know there's a cleaner way to do this.  All I want to do is print a
> word, but have more than one test case.  I'd like to do it in the <%
> %> print operator, but haven't been able to figure that out.
> 
> % if ( $ads = 'is_web' ) {
you mean "eq"

> Web Only
> % } elsif ( $ads = 'is_print' ) {
ditto

> Print
> % } else {
> Web and Print
> % }
> 
> I'm printing this in a <td> tag so it make the code a little messy.
> 
> Any suggestions are greatly appreciated,

<td><% $ads eq 'is_web ? 'Web Only' : $ads eq 'is_print ? 'Print' : 'Web
and Print' %></td>

Ugly and usually not acceptable (IMO, for more than 3 alternatives).
Use a mapping method is you have more cases. The simplest example:

<%perl>
  my %ads_map = (
    'is_web'   => 'Web Only',
    'is_print' => 'Print',
    _default   => 'Web and Print'
  );
<%/perl>
<td><% $ads_map{$ads} || $ads_map{_default} %></td>

cheers.
- --
Marius Feraru
-----BEGIN PGP SIGNATURE-----

iD8DBQFEyI3JtZHp/AYZiNkRAm1iAKDux4PHIkiiQ7rZUsrQ21Jycn11GwCdEhx5
iSKCa83Zru43evgLK90Sz4I=
=h1hl
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
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

Reply via email to