in reply to Mojo Template, passing dynamic index to array.

Why not keep it simple and pass $street?
  • Comment on Re: Mojo Template, passing dynamic index to array.

Replies are listed 'Best First'.
Re^2: Mojo Template, passing dynamic index to array.
by marto (Cardinal) on Jul 14, 2021 at 10:37 UTC

    Not sure why this got downvoted, passing a few variables with the values for the 'row' in question in most cases makes more sense than passing an entire data structure then displaying one 'row' from a result set.

      I understood $number as loop var, loading it into a temporary $street var would lead to more code.

      YMMV...

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        That's one way to look at it. Both are assumptions without OP providing proper context. I often see people pass large data structures to templates, only to never reference most of it.

      Maybe because AnonyMonk in this case was inferring an XY problem when there really isn't one. The OP actually needs to know how to do what he was trying to do; offering him a kludgy workaround isn't doing him any favors.

        No 'work around' was offered, since the problem posted was addressed elsewhere in the thread. An alternative approach which makes perfect sense in common use cases.