This example...
-----
#!/usr/bin/perl -w
use strict;
my %commas = (
'notalot' => 1,
'england,rugby' => 1,
'chicken,egg,duck,feet' => 1,
',southampton' => 0,
'bristol,' => 0,
'iran,,canada,france' => 0,
);
foreach my $key (keys %commas)
{
unless (($key =~ /^,|,,|,$/))
{
print "PASS";
}
else
{
print "FAIL";
}
print ": $key\n";
}
----
... seems to work for me. This was it's output:
FAIL: bristol,
PASS: notalot
PASS: england,rugby
FAIL: iran,,canada,france
PASS: chicken,egg,duck,feet
FAIL: ,southampton