#!/usr/bin/perl use strict; use DBI; open(LOG, "<20060620.act"); while (<LOG>){ chomp; my @values = split(',',$_); s/^"&"$/ $_ /g; my $dbh = DBI->connect ('dbi:mysql:radius', 'radiususr', 'radiuspass') || die "Database connection not +made! $DBI::errstr"; foreach my $value(@values){ if($value =~ 'Stop'){ my $sql = "insert into acct1(date, time, RAS_CLIENT, Called_Station_Id, Calling_Station_Id, Acct_Input_Octets, Acct_Output_Octets, Acct_Session_Time, Acct_Input_Packets, Acct_Output_Packets, Acct_Termination_Cause) values(@values[0], @values[1], @values[2], @values[28], @values[29], @values[34], @values[35], @values[38], @values[39], @values[40], @values[41], @values[42])"; my $sth = $dbh->prepare($sql); $sth->bind_param(1,$_->[0]); $sth->bind_param(2,$_ ->[1]); $sth->bind_param(3,$_ ->[2]); $sth->bind_param(4,$_ ->[3]); $sth->bind_param(5,$_ ->[4]); $sth->bind_param(6,$_ ->[5]); $sth->bind_param(7,$_ ->[6]); $sth->bind_param(8,$_ ->[7]); $sth->bind_param(9,$_ ->[8]); $sth->bind_param(10,$_ ->[9]); $sth->bind_param(11,$_ ->[10]); $sth->bind_param(12,$_ ->[11]); $sth->execute(); $dbh->commit(); if ($@) { warn "Database error: $DBI::errstr \n"; $dbh->rollback(); } $dbh->do($sql); $sth->finish(); $dbh -> disconnect (); }

ERROR OBTAINED:::
******************

Can't use string (""06/19/2006","23:59:48","CSCVPN0") as an ARRAY ref +while "strict refs" in use at try1.pl line 60, <LOG> line 1048.

SAMPLE FILE DATA:::
*********************

"06/19/2006","23:59:48","CSCVPN01","Stop","Unknown","Unknown","bmikulk +a","172.22.0.5","946674","8","1","172.22.0.85","255.255.224.0",,,,,,, +,,,,,"ou=pcna","82800","900",,,,"CSCVPN01",,"2","14","108311","503278 +","000E71F2",,"248","806","821",,,,"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, "06/20/2006","00:00:05","DFWAS1.PBSG.PVT","Stop","tmoy@PBGPPShh","200" +,"tmoy@PBGPPShh","172.21.64.20","392","2","1","172.21.64.86",,,,,,,,, +,,,,"SBR-CL DN="tmoy@PBGPPShh" AT="200" VR="SybaseRealm"",,,,"0963"," +2157251159","DFWAS1.PBSG.PVT",,"2","0","8841","119703","00029926","1" +,"219","79","113","1",,,"0",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,, "06/19/2006","23:59:51","DFWVPN01M.PBSG.PVT","Stop","Unknown","Unknown +","03138981","172.21.0.5","2042656","8","1","172.21.0.123","255.255.2 +24.0",,,,,,,,,,,,"ou=fritolay","82800","900",,,,"DFWVPN01M.PBSG.PVT", +,"2","15","17850309","24857452","001F2B20",,"5276","28956","31809",,, +,"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,, "06/19/2006","23:59:57","DFWVPN01M.PBSG.PVT","Stop","Unknown","Unknown +","02036855","172.21.0.5","2042739","8","1","172.21.0.100","255.255.2 +24.0",,,,,,,,,,,,"ou=troppilot","82800","900",,,,"DFWVPN01M.PBSG.PVT" +,,"2","9","7621521","15661250","001F2B73",,"4147","29079","27876",,,, +"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,, "06/20/2006","00:00:06","CSCVPN01","Stop","Unknown","Unknown","0117152 +5","172.22.0.5","946672","8","1","172.22.0.73","255.255.224.0",,,,,,, +,,,,,"ou=pcna","82800","900",,,,"CSCVPN01",,"2","11","125891","157892 +","000E71F0",,"447","621","560",,,,"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

20060628 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

20060629 Janitored by Corion: Added READMORE tag


In reply to Strict Ref : ERROR by swetashah23

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.