# When it is not typed, the arguments will start as "" blank
# (which means all ids)
@id = "";
# Check typed argument ("-id1", duplicated or none)
foreach my $arg (@ARGV)
{
if ($arg =~ /^--?id(\d+)$/)
{
die "Error: Multiple ids specified: -id@id and $arg.\n" if ($id[0]);
@id = $1 ; next;
}
}
# Exec problem
if ($id[0] eq "")
{
my $sql = "SELECT DISTINCT id FROM mytable WHERE active = ?";
@id = @{$dbh->selectall_arrayref($sql,undef,'no')};
print join (", ", @id), "\n";
}
####
Running SELECT id FROM mytable WHERE id=? AND salary >= 1 for ARRAY(0x1011e70)
ID: ARRAY(0x1011e70), 1 lines dumped to csvfile1_ARRAY(0x1011e70).csv
####
Argument "" isn't numeric in subroutine entry at ./test.pl line 108.