Shaveta_Chawla has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Author separation
by kcott (Archbishop) on Jun 07, 2012 at 08:08 UTC
Re: Author separation
by DrHyde (Prior) on Jun 07, 2012 at 09:49 UTC
    That's easy.
    if($author eq "Cheng, Liying, Fox, Janna., and Zheng, Ying. ") { $author = "Liying Cheng, Janna. Fox, Ying. Zheng "; }
    If you want something that works in the general case, then I suggest that you start by showing us what you've tried.
      I have used this code:
      $author = "Cheng, Liying, Fox, Janna., Zheng, Ying."; @author = split(',' , $author); $length = scalar(@author); $l = 0; $j = 1; for($i=0; $i<$length/2 ; $i++) { $author1[$i]= "$author[$j] $author[$l]"; $l = $l+2; $j = $j+2; } $author = join (',' , @author1); print "$author\n\n";
      but this is not feasible
Re: Author separation
by cdarke (Prior) on Jun 07, 2012 at 13:05 UTC
    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
Re: Author separation
by Shaveta_Chawla (Sexton) on Jun 07, 2012 at 11:05 UTC
    This code can also be used::
    $author = "$author,"; $author =~ s/(.*?),(.*?),/$2 $1,/g;