#!/usr/bin/perl chomp ($a = <>); for (sort split /,\s*|\s+/, $a) { print "$_\n" }