Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Expression form of map or grep

by Lady_Aleena (Curate)
on Jul 12, 2020 at 12:19 UTC ( #11119207=note: print w/replies, xml ) Need Help??


in reply to Re: Expression form of map or grep
in thread Expression form of map or grep

It was my intent for @grey_scale to be part of @list, but not have "beads" mapped to it. I have a few modules that are lists starting with or have a map in the middle of the list, here is an example:

'troll' => ['troll', map( "$_ troll", qw(desert freshwater giant ice s +altwater snow spectral), 'two-headed'), 'trobold', @$tralg, @$throgli +n]

I have a plain troll, then map "troll" to the end of several, then the trobold, then 2 more lists of types of trolls. The module that is in is here. Several of my random modules have that.

My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena

Replies are listed 'Best First'.
Re^3: Expression form of map or grep
by parv (Vicar) on Jul 13, 2020 at 05:53 UTC

    In the code as shown, "map" just melds in the array reference construction. Perhaps that is what you prefer.

    I personally would either make a temporary variable to hold the map result; or rearrange the code to highlight map function. On the second note ...

    'troll' => [ 'troll', map( "$_ troll", qw(desert freshwater giant ice saltwater snow spectr +al), 'two-headed' ), 'trobold', @$tralg, @$throglin ]

      I could spread it out, but there are almost 100 lists like it in the module. That is almost 100 lines Perl::Critic does not like too.

      My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena

        Why do you care about number of lines for their own sake? The example had 1 single statement; after spreading that out, there was still only 1 statement.

        The added whitespace out was not for Perl::Critic. It was for my own sake, and for any future maintainer including myself, to make it easier to see that the array reference was not just a plain word list.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2020-09-28 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (144 votes). Check out past polls.

    Notices?