>>>>> "EW" == Erik Witkop <ewit...@gmail.com> writes:

  EW> I have spent half the day looking at map and I still don't get it.

it is easier than you think.

  EW> I don't get the EXPR versus BLOCK and how I can treat them differently.

that is mostly a syntax difference. you can have a single expression,
then a comma then the list OR a {} block of code, NO comma and a
list. the block allows you to declare variables, have multiple
statements, etc. some always use a block and for simple expressions it
is the same as the EXPR one.

  EW> I think I am close but my regex is not hitting.

  EW> @final_results = map { m/^[a-zA-Z0-9]{3,4}?$/$1/ } @just_cust_codes;

you aren't GRABBING anything. this is not a map issue but a regex
one. people showed you how to do this in replies. why didn't you use
their code?

secondly m// has TWO slashes, and you have 3. you are NOT doing a
substitution but a simple grab. and you aren't even doing a grab as
there are no parens. a regex in list context (like in a map) will return
its grabs so map will return them. no need for any $1 stuff.

  EW> I see a lot of people use a question mark in there, but I am unsure why.

  EW> All I want is the regex above to be in $1 for me to access.

no you don't. it will be returned if you just use the code others have
posted. then ask how that code works. you are guessing and typing random
noise in hope that something will work. you need to understand how
regexes AND map work together.

  EW> Any help would be appreciated.

  EW> p.s. I read perldoc -f map, and checked my camel book. I am honestly at a
  EW> loss.

did you read perldoc perlretut? and then perldoc perlre? the issue is
more regex than map.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to