CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Why do I keep getting this error?

 



cuboidgraphix
User

Jan 28, 2009, 7:22 AM

Post #1 of 3 (1631 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?



Code
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.


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();



shawnhcorey
Enthusiast


Jan 28, 2009, 7:24 AM

Post #2 of 3 (1630 views)
Re: [cuboidgraphix] Why do I keep getting this error? [In reply to] Can't Post

Change

print $CSV "$DATE,$TIME,$TOTU,$TRAFFIC,$SERVERS\n";

to

print $FH "$DATE,$TIME,$TOTU,$TRAFFIC,$SERVERS\n";

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


cuboidgraphix
User

Jan 28, 2009, 7:33 AM

Post #3 of 3 (1628 views)
Re: [shawnhcorey] Why do I keep getting this error? [In reply to] Can't Post

Thanks Shawn ... I caught on to it right as I posted. lol

I've been looking at it for the past 15 minutes and couldn't figure it out.. As soon as I posted it on the forum.. I noticed it. Talk about looking at things in a new perspective.. :)

Thanks.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives