Hi... I have a Perl Script which will extract statistics from DB2 database. But when i try to run it using ./filename.pl It ends up with --> syntax error at ./run_db2look.pl line 61, at EOF Execution of ./run_db2look.pl aborted due to compilation errors (#1) Do i need to pass the parameters from the beginning. Plz provide me an solution.
#!/usr/bin/perl -w # use Getopt::Std; use Time::Local; use diagnostics; use warnings; getopt('d:', \%params); my $database = uc($params{"d"}); die "Usage: $0 -d <database>" unless ($database); my $result; $/ = undef; #connect db $result = `db2 connect to $database`; die "$0: Cannot connect to database $database.\n$result" unless ($? + eq 0); #run db2 command $result = `db2 "select tabname from syscat.tables where STATS_TIME +>= TRUNC(current timestamp) - 7 days and TABSCHEMA = 'TCSUPER'"`; my $close = `db2 connect reset`; die "$0: Cannot close connection to database $database.\n$close" un +less ($? eq 0); `db2 terminate`; # print current timestamp my $now = `date`; print "$now\n"; @records = split(/\n/, $result); ## removing last element in array. my $retval = pop(@records); $cnt = 1; $table_list = ""; foreach my $record (@records) { ## remove headers in the results if ($cnt > 3 ) { #trim white spaces $record =~ s/^\s+//; $record =~ s/\s+$//; if (length($record) > 0 ) { print "$cnt : |$record| " . length($record) . "\n"; $table_list .= " " . $record; ##print "$table_list\n"; } } $cnt++; } print $table_list; #excute db2look from the table lists `db2look -d tcard -m -t $table_list -o dl.out`; exit; ~
In reply to Compilation Error by ai_zaviour
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |