in reply to Re: Changing the order of elements in the variable
in thread Changing the order of elements in the variable

That's fantastic.. But one comma (,) is missed- it seems.
$author =~ s/([^,;]+),([^,;]+)/$2, $1/g;

Replies are listed 'Best First'.
Re^3: Changing the order of elements in the variable
by kcott (Archbishop) on May 30, 2012 at 11:30 UTC

    You can check this sort of thing on the commandline: usually advisable if you're going to tell someone they got something wrong.

    Shaveta_Chawla wants: "... "Smith, Kristen A." should change to "Kristen A. Smith".".

    moritz' solution does this:

    $ perl -Mstrict -Mwarnings -E 'my $author = q{Smith, Kristen A.}; $aut +hor =~ s/([^,;]+),([^,;]+)/$2 $1/g; say $author' Kristen A. Smith

    Your correction does not do this:

    $ perl -Mstrict -Mwarnings -E 'my $author = q{Smith, Kristen A.}; $aut +hor =~ s/([^,;]+),([^,;]+)/$2, $1/g; say $author' Kristen A., Smith

    -- Ken