
cuboidgraphix
User
Jan 28, 2009, 7:22 AM
Post #1 of 3
(1015 views)
|
|
Why do I keep getting this error?
|
Can't Post
|
|
Hi guys, Could you please tell me why I keep getting the following error?
Can't use string ("/home/switch/erlang/data/log0901") as a symbol ref while "strict refs" in use at ./get.pl line 44. This is my code.
#!/usr/bin/perl # This file is the sendupdate.pl # This is a script that will query the MySQL database for current alarms # and send them through an SMS with Python. It will then update the MySQL database. use strict; use warnings; use DBI; use DBD::mysql; use POSIX qw/strftime/; use Math::Telephony::ErlangB qw( :all ); my $DAY = strftime("%y%m%d", localtime(time)); my $YDAY = strftime("%Y-%m-%d", localtime(time - 86400)); my $HOST = 'localhost'; my $DB = 'HOST'; my $TABLE1 = 'TABLE'; my $USR = 'USR'; my $PWD = 'PWD'; my $DIR = "/home/switch/erlang/data/"; # Data source name my $DSN = "dbi:mysql:$DB:localhost:3306"; # Perl DBI connect my $DBH = DBI->connect($DSN, $USR, $PWD); # Prepare and execute query my $QUERY = "SELECT DATE, TIME, SUM(TOTU) AS 'TOTU', SUM(TOTU)/36 AS 'TRAFFIC' FROM $TABLE1 WHERE DATE >= '$YDAY' GROUP BY DATE, HOUR(TIME)"; my $STH = $DBH->prepare($QUERY); $STH->execute(); # Binding table column to a variable my($DATE, $TIME, $TOTU, $TRAFFIC, $BPROB, $SERVERS, $FH); $STH->bind_columns(undef, \$DATE, \$TIME, \$TOTU, \$TRAFFIC); # Loop through results and get the smart number. while($STH->fetch()) { $BPROB = .01; $SERVERS = servers($TRAFFIC, $BPROB); my $CSV = $DIR."log".$DAY.".csv" || die "Usage: $0 <filename>\n"; open $FH, '>>', $CSV or die "Can't open '$CSV' $!"; print $CSV "$DATE,$TIME,$TOTU,$TRAFFIC,$SERVERS\n"; close $FH; } $STH->finish(); $DBH->disconnect();
|