develooper Front page | perl.beginners | Postings from December 2011

issue with perl map function

From:
Sunita.Pradhan
Date:
December 2, 2011 01:39
Subject:
issue with perl map function
Message ID:
3A046B8D0B71BD4790EA3FB35CF40CE1152BCE7E99@MX34A.corp.emc.com
Hi All

                My  array  @sympd_list has  following lines :
--------------------
/dev/sdd               0BE0 07F:0 08C:D0  Unprotected   N/Grp'd      RW     500
/dev/sde               0BE1 07F:0 07A:C0  Unprotected   N/Grp'd      RW     500
/dev/sdf               0BE2 07F:0 08D:C0  Unprotected   N/Grp'd      RW     500
/dev/sdg               0BE3 07F:0 07B:D0  Unprotected   N/Grp'd      RW     500
/dev/sdj               201A 07H:0 07A:D5  Unprotected   N/Grp'd      RW       3
---------------------------


I  want second column in another array :

0BE0
0BE1
0BE2
0BE3
201A

I used map function with pattern matching  as >>> my @sympd_dev_list = map {$_ =~ s/^\/\S+\s+([0-9A-F]{4}).+/$1/ } @sympd_list;

I do not get correct output in map function . But if I use same pattern matching in a foreach loop , then I get right output .

Could anyone tell me what is wrong in my map function ?

-Sunita






nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About