Re: Unable to understanding map usage

2013-07-24 Thread *Shaji Kalidasan*
ot;,"mangoes" [/code] [output] "'apples'","oranges","'guavas'","cherri'es","mangoes" [/output]   best, Shaji ------- Your talent is God's gift to you. What you do with it is your gift back to God. --

Re: Unable to understanding map usage

2013-07-24 Thread *Shaji Kalidasan*
d's gift to you. What you do with it is your gift back to God. ------- From: Rajeev Kilaru To: beginners@perl.org Sent: Thursday, 25 July 2013 12:14 AM Subject: Unable to understanding map usage

Re: Unable to understanding map usage

2013-07-24 Thread Jim Gibson
On Jul 24, 2013, at 12:33 PM, Shawn H Corey wrote: > On Wed, 24 Jul 2013 12:25:16 -0700 > Jim Gibson wrote: > >> In your case, BLOCK is >> >> { $_=~ s/\"/\'/g; "\"$_\"" } >> >> and LIST is @data. Therefore, each element of @data is aliased to $_, >> the substitution s//\"/\'/g is performed

Re: Unable to understanding map usage

2013-07-24 Thread Shawn H Corey
On Wed, 24 Jul 2013 12:25:16 -0700 Jim Gibson wrote: > In your case, BLOCK is > > { $_=~ s/\"/\'/g; "\"$_\"" } > > and LIST is @data. Therefore, each element of @data is aliased to $_, > the substitution s//\"/\'/g is performed on it, which changes all > double-quote characters to single-qu

Re: Unable to understanding map usage

2013-07-24 Thread Jim Gibson
On Jul 24, 2013, at 11:44 AM, Rajeev Kilaru wrote: > Hello, > > I am looking at the following code someone wrote and I have > difficultly in understand map usage. Can somebody please explain how > does the following code work? > > print OUT2 join( ',', map { $

Unable to understanding map usage

2013-07-24 Thread Rajeev Kilaru
Hello, I am looking at the following code someone wrote and I have difficultly in understand map usage. Can somebody please explain how does the following code work? print OUT2 join( ',', map { $_=~ s/\"/\'/g; "\"$_\"" } @data ) Thanks, Rajeev Kilar

Re: map usage

2012-02-20 Thread John W. Krahn
Manfred Lotz wrote: Hi there, Hello, I have a hash table where I want to do some action for each value in the hash table. Among other possibilities I could do like this: map { some_action($_) } values %ht; where let us say: sub some_action { ... return; } I like it because it

Re: map usage

2012-02-20 Thread Manfred Lotz
On Mon, 20 Feb 2012 20:14:13 +0100 "Christian Walde" wrote: > On Mon, 20 Feb 2012 20:08:31 +0100, Manfred Lotz > wrote: > > > Hi there, > > > > I have a hash table where I want to do some action for each value in > > the hash table. > > > > > > > > Among other possibilities I could do like this

Re: map usage

2012-02-20 Thread Manfred Lotz
On Mon, 20 Feb 2012 20:08:31 +0100 Manfred Lotz wrote: > Hi there, > > I have a hash table where I want to do some action for each value in > the hash table. > > > > Among other possibilities I could do like this: >map { some_action($_) } values %ht; > > where let us say: > > sub some_

Re: map usage

2012-02-20 Thread Christian Walde
On Mon, 20 Feb 2012 20:08:31 +0100, Manfred Lotz wrote: Hi there, I have a hash table where I want to do some action for each value in the hash table. Among other possibilities I could do like this: map { some_action($_) } values %ht; where let us say: sub some_action { ... retu

map usage

2012-02-20 Thread Manfred Lotz
Hi there, I have a hash table where I want to do some action for each value in the hash table. Among other possibilities I could do like this: map { some_action($_) } values %ht; where let us say: sub some_action { ... return; } I like it because it is really short. Questions:

Re: about map usage

2006-09-13 Thread Igor Sutton
my %hash = map { $_, 1 } @array; What is the usage of 1 in this code? When you have any kind of doubt about a Perl structure, you can use Data::Dumper: use Data::Dumper; my %hash = map { $_, 1 } @array; print Dumper \%hash; Try it! -- Igor Sutton Lopes t: +55 51 9627.0779 e: [EMAIL PROTE

Re: about map usage

2006-09-13 Thread jeffhua
L PROTECTED] To: beginners@perl.org Sent: Wed, 13 Sep 2006 9:38 PM Subject: about map usage Hi all, In perlfaq4.pod I see one line: my %hash = map { $_, 1 } @array; What is the usage of 1 in this code? Thanks, Li __ Do You Yahoo!? Tired of spa

Re: about map usage

2006-09-13 Thread Rob Coops
What this does is creating a hash that looks like this: %hash { $array[0] => 1, $array[1] => 1, $array[2] => 1, $array[3] => 1, ect. } It is a (posibly the quickest way) of changing a array into a hash. Hope it helps. On 9/13/06, chen li <[EMAIL PROTECTED]>

about map usage

2006-09-13 Thread chen li
Hi all, In perlfaq4.pod I see one line: my %hash = map { $_, 1 } @array; What is the usage of 1 in this code? Thanks, Li __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsub