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.
--
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
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
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
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 { $
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
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
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
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_
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
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:
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
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
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]>
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
15 matches
Mail list logo