Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Perl Swap

Options
  • 14-04-2009 12:25pm
    #1
    Registered Users Posts: 465 ✭✭


    Hi

    I want to swap all commas for full stops and all full stops for commas.
    Anyone know how to do the compare and swap at the same time so I am not undoing a swap?

    $_ =~ s/./,/gi; works fine for swapping '.' with ','

    Thanks
    Coco


Comments

  • Registered Users Posts: 66 ✭✭bala


    coco06 wrote: »
    Hi

    I want to swap all commas for full stops and all full stops for commas.
    Anyone know how to do the compare and swap at the same time so I am not undoing a swap?

    $_ =~ s/./,/gi; works fine for swapping '.' with ','

    Thanks
    Coco

    try

    $_ =~ tr/[.,]/[,.]/;


  • Registered Users Posts: 465 ✭✭coco06


    thanks for that ;)


Advertisement