Wednesday, May 22, 2013

How do you get current timestamp in Perl?

#!/usr/bin/perl

use DateTime;

my $dt=DateTime->now;

$TimeStamp=$dt->ymd . "_" . $dt->hms;

How could you interpolate/execute UNIX commands within double quote?

write_log ("working directory is : @{[qx!pwd!]}");

How could you interpolate/execute perl functions within double quote?

use @{[ ]}.

write_log ("Execution of $0 started at @{[scalar (localtime)]}.\n");

Tuesday, May 14, 2013

How do you find all the tables with specific column names in MySQL?

SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ( 'ColumnA', 'ColumnB' )
AND TABLE_SCHEMA = 'DatabaseName';