You don't show us what output you get, and what output you expect, so it's somewhat hard to give you concrete advice. If you post an example and tell us where you think it goes wrong, that makes it much easier for us to address your actual misunderstandings.
join takes a list, so you don't need a for loop to build up the string from @nfirst.
If you call join with only one parameter, it will not prepend or append a space, so this line makes little sense:
$newfirst .= join(" ",(ucfirst $nfirst[$i]) );
A good approach here would be to first convert all first names to ucfirst using map:
@nfirst = map { ucfirst $_ } @nfirst;
... then you can use join directly:
my $NewFirst = join " ", @nfirst;
You can also do this in one go:
my $NewFirst = join " ", map { ucfirst $_ }, split /\s+/, $first ;
In reply to Re: trying to use join in a loop
by Corion
in thread trying to use join in a loop
by lamasculo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |