Re: How to map hash keys only, not values?

2003-03-14 Thread R. Joseph Newton
[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

Re: How to map hash keys only, not values?

2003-03-14 Thread Peter_Farrar
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

Re: How to map hash keys only, not values?

2003-03-13 Thread R. Joseph Newton
[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

Re: How to map hash keys only, not values?

2003-03-13 Thread david
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

Re: How to map hash keys only, not values?

2003-03-13 Thread John W. Krahn
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/} @_;

Re: How to map hash keys only, not values?

2003-03-13 Thread R. Joseph Newton
[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

Re: How to map hash keys only, not values?

2003-03-13 Thread Peter_Farrar
>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]

Re: How to map hash keys only, not values?

2003-03-13 Thread R. Joseph Newton
[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

Re: How to map hash keys only, not values?

2003-03-13 Thread Randal L. Schwartz
> "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?

Re: How to map hash keys only, not values?

2003-03-13 Thread Peter_Farrar
>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

RE: How to map hash keys only, not values?

2003-03-13 Thread NYIMI Jose (BMB)
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

Re: How to map hash keys only, not values?

2003-03-13 Thread Randal L. Schwartz
> "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

Re: How to map hash keys only, not values?

2003-03-13 Thread Peter_Farrar
>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;

Re: How to map hash keys only, not values?

2003-03-13 Thread Randal L. Schwartz
> "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>