Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

If you want to omit characters, you can write
my %hash = map $_=>1, qw(shave the modern way);

Interestingly, you can't. If you want to remove the block you need to have

map +($_ => 1), ...
as => is a comma, so what you actually wrote is equivalent to these two statements below.
my %hash = map $_, 1, qw(shave the modern way); my %hash = map { $_ } 1, qw(shave the modern way);

(If you write map ($_ => 1), LIST the "function rule" kicks in and it becomes map($_ => 1), LIST i.e. (map $_, 1), LIST.)

This means that you can write

map f($_) => LIST
which one could read declaratively as "map the function f onto the list I'm pointing at". Personally though I usually think of map as acting in the other direction, "shifting" of one element at a time from the list.

lodin


In reply to Re^6: Effeciency of key-only hash (map EXPR => LIST) by lodin
in thread Effecicncy of key-only hash by brycen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2022-05-23 20:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?