http://www.perlmonks.org?node_id=473524


in reply to Re^3: How do i extract 3 variables from each line in a file, and print them to a new file
in thread How do i extract 3 variables from each line in a file, and print them to a new file

good question.. hope I'm not overstepping my bounds by responding..(and I hope I'm right!)

map { $_ =~ s/\D//g; $_ } split(':',(split(' ',$_))[-1]);
is equivalent to
my @split_results = split(':',(split(' ',$_))[-1]); map { $_ =~ s/\D//g; $_ } @split_results;
because map BLOCK LIST has to run the BLOCK for each LIST element (setting each LIST value to $_), it must know what is in that LIST. Hence, the execution of the split(s) before the execution of the BLOCK (and therefore the map).
  • Comment on Re^4: How do i extract 3 variables from each line in a file, and print them to a new file
  • Select or Download Code

Replies are listed 'Best First'.
Re^5: How do i extract 3 variables from each line in a file, and print them to a new file
by bofh_of_oz (Hermit) on Jul 08, 2005 at 18:18 UTC
    Oh, I see. I guess it's the space between map{} and split that threw me off as i'm not used to using map yet :)

    Thanks for nice explanation as well. (I'll ++ you later as I've used up my votes for today already ;)

    --------------------------------
    An idea is not responsible for the people who believe in it...