Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Author separation

by cdarke (Prior)
on Jun 07, 2012 at 13:05 UTC ( #974932=note: print w/ replies, xml ) Need Help??


in reply to Author separation

Many ways of doing this, here is mine:

use strict; use warnings; my $author = "Cheng, Liying, Fox, Janna., and Zheng, Ying. "; $author =~ s/\.| and| //g; my %hash = split (',', $author); my @authors; for my $key (sort keys %hash) { push @authors,"$hash{$key} $key"; } $author = join(',', @authors); print "$author\n";
Gives:
Liying Cheng,Janna Fox,Ying Zheng


Comment on Re: Author separation
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2015-07-03 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls