I like to format my sql statements so they are a little more easily read, just a preference, Try this statement, Using the double quotes in perl will allow you to use constants(i.e hardcoded values) and perl variables which perl will use the actual value:
my @data = ( 123456, "'ent_name'", 123456, "'grp_name'", "'dev_name'", "'dev_type'" );
my $date = "2012-03-16-13.00.00";
my $julianday = "076";
my $mac_address = "'2C-3F-45-02-1B-32'";
## For this examples sake, I'm assuming oracle sql, if it's not then the sql syntax might be different:
$query = "" .
"update digi_master\n" .
" set enterprise_id = $data,\n" .
" enterprise_name = $data,\n" .
" group_id = $data,\n" .
" group_name = $data,\n" .
" device_name = $data,\n" .
" device_type = $data\n" .
" where date = to_date( $date, 'yyyy-mm-dd-hh24.mi.ss' )\n" .
" and julianday = $julianday\n" .
" and mac_address = $mac_address\n";
Quite often I see a lot of string concatenation statements being used to build the string for an SQL command, e.g. SQL SELECT statement:
$Stmt = "select *\n"
. " from $UserTable\n"
. " where $QueryColumn = '$UserInput'";
This gets much worse for a long INSERT statement with 10 columns.
Suggestion is to use Perl HERE-Doc literal:
my $SQL_String = <<__END_OF_HERE_DOC__;
where $QueryColumn = '$UserInput'
As a post-script to Bill Cowan's advice (above), the absence of quotes means that Perl variables will be interpolated, even the one for $UserInput, above. If you want no variables to be interpolated (suppose you need to address v$session in Oracle), then wrap the __END_OF_HERE_DOC__ in single quotes: '__END_OF_HERE_DOC__';