in reply to Avoiding duplicate filenames

As Corion suggested, use a LIKE query

# Remove non-alphanumeric characters # and replace them with spaces $title =~ s/[^\w| ]/ /g; my @words = split /\s+/, $title; my $filename = join '-',$date,@words; # check to see if filename is being used my $table = 'FILENAMES'; my $sql = "SELECT filename FROM $table WHERE filename LIKE ?"; my $res = $dbh->selectall_arrayref($sql,undef,$filename.'%'); my %hash = map {$_->[0]=>1} @$res; my $i=''; while ( exists $hash{$filename.$i.'.html'} ){ ++$i; ++$i if $i==1; } my $sql_i = "INSERT INTO $table (filename) VALUES (?)"; $dbh->do($sql_i,undef,$filename.$i.'.html');
poj