Re: Can I map this

2007-04-04 Thread Rob Dixon
Beginner wrote: I have a list of names all in uppercase that I would like to capitaIise. I can't help but think that map could make short work of this loop but I am not sure how. Is it possible to use map here instead of a for loop? I can see there are going to be issues with double-barrelle

Re: Can I map this

2007-04-04 Thread Igor Sutton Lopes
On 2007/04/04, at 18:12, Randal L. Schwartz wrote: "Igor" == Igor Sutton Lopes <[EMAIL PROTECTED]> writes: Igor> my $str = join( " ", map { s/\B(\w+)/\L\1/; $_ } split( / \s+/, $_ ) ); It's bad style to modify $_ in a map, because that also modifies the incoming data. The simplest

Re: Can I map this

2007-04-04 Thread John W. Krahn
Beginner wrote: > Hi All, Hello, > I have a list of names all in uppercase that I would like to > capitaIise. I can't help but think that map could make short work of > this loop but I am not sure how. Is it possible to use map here > instead of a for loop? I can see there are going to be issu

Re: Can I map this

2007-04-04 Thread Randal L. Schwartz
> "Igor" == Igor Sutton Lopes <[EMAIL PROTECTED]> writes: Igor> my $str = join( " ", map { s/\B(\w+)/\L\1/; $_ } split( /\s+/, $_ ) ); It's bad style to modify $_ in a map, because that also modifies the incoming data. The simplest workaround is adding local: @out = map { local $_ = $

Re: Can I map this

2007-04-04 Thread John W. Krahn
Beginner wrote: > Hi All, Hello, > I have a list of names all in uppercase that I would like to > capitaIise. I can't help but think that map could make short work of > this loop but I am not sure how. Is it possible to use map here > instead of a for loop? I can see there are going to be issu

Re: Can I map this

2007-04-04 Thread Jason Roth
my $str = join " ", map { ucfirst lc } @words; should do what your for loop is doing. -Jason On 4/4/07, Beginner <[EMAIL PROTECTED]> wrote: Hi All, I have a list of names all in uppercase that I would like to capitaIise. I can't help but think that map could make short work of this loop but I

Re: Can I map this

2007-04-04 Thread Igor Sutton Lopes
On 2007/04/04, at 16:28, Beginner wrote: while () { my @words = split(/\s+/,$_); my $str; foreach my $w (@words) { my $s = lc($w); $s = ucfirst($s); $str .= $s.' '; } print "STR=$str\n"; } __DATA__ SOME NAME SOMEONE WITH FOUR NAMES ONE WITH THREE A-HYPENED NAME

Can I map this

2007-04-04 Thread Beginner
Hi All, I have a list of names all in uppercase that I would like to capitaIise. I can't help but think that map could make short work of this loop but I am not sure how. Is it possible to use map here instead of a for loop? I can see there are going to be issues with double-barrelled names bu