[EMAIL PROTECTED] wrote:
> Hi Joseph,
>
> >Probably just as well. Is there some context where you anticipate having
> to repair broken keys after the fact?
>
> In this case I'm building packages, and don't want to count on the user to
> get the case of the text correct when passing the values.
L
Hi Joseph,
>Probably just as well. Is there some context where you anticipate having
to repair broken keys after the fact?
In this case I'm building packages, and don't want to count on the user to
get the case of the text correct when passing the values. So if I need to
set the 'smile' attrib
[EMAIL PROTECTED] wrote:
> >Replace
> >
> > EVIL: map { some;block;of;code;that;changes;$_ } @some_array;
> >
> >with
> >
> > GOOD: for (@some_array) { some;block;of;code;that;changes;$_ }
>
> I guess I don't get it. Map returns a value and I ignore it; so what?
> What side effects does this ha
Randal L. Schwartz wrote:
>> "Peter" == Peter Farrar <[EMAIL PROTECTED]> writes:
>
>>> Replace
>>>
>>> EVIL: map { some;block;of;code;that;changes;$_ } @some_array;
>>>
>>> with
>>>
>>> GOOD: for (@some_array) { some;block;of;code;that;changes;$_ }
>
>
> The foreach loop *will* be faster
Peter Farrar wrote:
>
> Hi All,
Hello,
> I'm passing a hash to a subroutine like this:
> subname("a" => 123, "b" =>"fff", "C" => "joyjoyjoy");
>
> On the receiving side I want all keys to be upper case. I can map like
> this:
> sub subname{
> map {$_ =~ tr/a-z/A-Z/} @_;
[EMAIL PROTECTED] wrote:
> Hi All,
>
> I'm passing a hash to a subroutine like this:
> subname("a" => 123, "b" =>"fff", "C" => "joyjoyjoy");
Hi Peter,
You probably sholdn't be doing this. Keys, whether in a hash or a database table, are
primary references. They should not be modified af
>The foreach loop *will* be faster.
Good enough for me!
Thanks,
Peter
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
> >First, please don't use map in a void context for its side effects.
>
> Uh oh... What side effects? I use map like this all the time! What dread
> is looming in my future?
Do:
perldoc -f map
and read carefully the second paragraph of discussion:
Note that
> "Peter" == Peter Farrar <[EMAIL PROTECTED]> writes:
>> Replace
>>
>> EVIL: map { some;block;of;code;that;changes;$_ } @some_array;
>>
>> with
>>
>> GOOD: for (@some_array) { some;block;of;code;that;changes;$_ }
Peter> I guess I don't get it. Map returns a value and I ignore it; so what?
>Replace
>
> EVIL: map { some;block;of;code;that;changes;$_ } @some_array;
>
>with
>
> GOOD: for (@some_array) { some;block;of;code;that;changes;$_ }
I guess I don't get it. Map returns a value and I ignore it; so what?
What side effects does this have? Which one's faster? I like to avoid
ob
unc manpage.
José.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 13, 2003 5:43 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: How to map hash keys only, not values?
>
>
>
>
> &g
> "Peter" == Peter Farrar <[EMAIL PROTECTED]> writes:
>> First, please don't use map in a void context for its side effects.
Peter> Uh oh... What side effects? I use map like this all the time! What dread
Peter> is looming in my future?
Replace
EVIL: map { some;block;of;code;that;change
>First, please don't use map in a void context for its side effects.
Uh oh... What side effects? I use map like this all the time! What dread
is looming in my future?
>Just loop it:
>
>sub subname {
> my %values;
> while (@_ >= 2) {
>my ($key, $value) = splice @_, 0, 2;
> "Peter" == Peter Farrar <[EMAIL PROTECTED]> writes:
Peter> Hi All,
Peter> I'm passing a hash to a subroutine like this:
Peter> subname("a" => 123, "b" =>"fff", "C" => "joyjoyjoy");
Peter> On the receiving side I want all keys to be upper case. I can map like
Peter> this:
Peter>
14 matches
Mail list logo