Shaveta_Chawla has asked for the wisdom of the Perl Monks concerning the following question:
this variable has author names , but my target is to change the order of individual author, like "Smith, Kristen A." should change to "Kristen A. Smith".
I have used the following code::@author = split(';', $author); $ca = scalar(@author); for (my $i=0; $i<$ca ; $i++) { ($a, $b) = split(',', $author[$i]); $author[$i] = "$b$a"; } $author = join(',', @author); print "$author\n";
i find this code really complex. Please suggest a better code using map function.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Changing the order of elements in the variable
by moritz (Cardinal) on May 30, 2012 at 06:59 UTC | |
by bimleshsharma (Beadle) on May 30, 2012 at 11:01 UTC | |
by kcott (Archbishop) on May 30, 2012 at 11:30 UTC | |
|
Re: Changing the order of elements in the variable
by choroba (Cardinal) on May 30, 2012 at 07:05 UTC | |
|
Re: Changing the order of elements in the variable
by MidLifeXis (Monsignor) on May 30, 2012 at 12:42 UTC | |
|
Re: Changing the order of elements in the variable
by uday_sagar (Scribe) on May 30, 2012 at 07:13 UTC |