Ok, I'm calling uncle...

I'm addmittedly not the best programmer in the world, I certainly enjoy working with perl and indulging the TMTOWTDI fact that Perl extends to all. I have previously posted regarding the map function. I now have successfully used it throughout my code, making it more readable and more efficient.
Recently I ran into the following problem, I was helping a fellow learn his first steps through perl and the logical approach to truth in perl. When I ran into a map problem, illustrated below:
my @delete_list = map {$_ =~ s/^delete_check_//} (grep /^delete_check_ +/, keys %session);
I had expected all the keys that contained the 'delete_check_' string at the beginning to be stripped and the remaining values to be populated into the @delete_list array. I instead got a relative number of 1's where I expected the results. I know that map returned a status, meaning, 1 "I've done the job you have requested". So, at this point I went through some of my old code and came up with:
my @delete_list = map {/^delete_check_(.*)/} (grep /^delete_check_/, k +eys %session);
This approach worked beautifully as I had expected. What I'm curious about is, what exactly do I need to pass to map inside the block to return the correct result? I'm still on the fence here regarding my full understanding of the map function. Therefore I'm worried that I have a bigger underlying issue of understanding when it comes to expressions and what exactly they are. Is it that map is one of the few functions in perl that needs special care on how you "express" yourself with it?


BlackJudas

Edit kudra, 2002-05-15 Changed title


In reply to help with s/// inside map by blackjudas

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.