Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Changing the order of elements in the variable

by bimleshsharma (Beadle)
on May 30, 2012 at 11:01 UTC ( #973259=note: print w/replies, xml ) Need Help??


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 (Chancellor) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://973259]
help
Chatterbox?
[erix]: (I used http://afstandmete n.nl/ )
LanX The stations of Limburg Süd and Montabaur, which are approximately 20 km apart, ...
[LanX]: teh route I get from gmaps is 1662 km long and is crossing the Swiss Alps (mounting 2400 m) ... I wouldn't try this in December...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2017-12-13 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?