Re: Debug Help Please

2008-07-14 Thread Peter Scott
On Mon, 07 Jul 2008 05:16:10 -0700, Andy wrote:
> One of the Perl guys at my office. told me that I can use
> use strict;
> use warnings;
> 
> but he said , he really doesn't because he wants the script to do what
> it needs to do...

And if one of "the car guys" at your office announced that he'd removed
his vehicle's air bags, seat belts, antilock brakes, and dashboard warning
lights and fuel gauge because he wants the car to "do what it needs to
do," would you repeat that advice to a panel of automotive experts as
though they should take note of it?

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Debug Help Please

2008-07-09 Thread Chris Charley


- Original Message - 
From: "Andy" <[EMAIL PROTECTED]>

Newsgroups: perl.beginners
To: 
Sent: Tuesday, July 08, 2008 9:31 PM
Subject: Re: Debug Help Please



On Jul 7, 2:16 pm, [EMAIL PROTECTED] (Andy) wrote:

On Jul 7, 11:53 am, [EMAIL PROTECTED] (Rob Dixon) wrote:



> Andy wrote:

> > Funny how when you talk to different people you get different ways of
> > looking at it.

> > One of the Perl guys at my office. told me that I can use
> > use strict;
> > use warnings;

> > but he said , he really doesn't because he wants the script to do 
> > what

> > it needs to do...

> Then he is a fool and should be disregarded. Perhaps he could post to 
> this group

> to explain himself?

> > I have made corrections as you suggested.
> >  I have included.

> > use strict;
> > use warnings;

> > as well as
> >  my $TIME  =$fields[3]

> > However after that ,
> > I still get zero output.

> > Maybe I have this written .

> Have you incorporated all the corrections that John posted in his first
> response? Perhaps you should post your program in its current state so 
> that we

> can take another look.

> Rob

Thank you all for the patience.

I have been doing some debugging...well as much of it as I can handle
with no exp...

This is the current code. I figured out with some help that My
$Dateroot was trying to read
incoming.xferlog.xferlog.csv.

Eventually I want to run "perl andylog.pl and it will Parse all the
xferlogs in the dir.

Thus far with all your help I have it working...now for the tweaks.

I have some lines longer than the other and I have to figure out how
to skip those lines ...

So now I have to figure out how to read them all even longer ones
Tue Apr 29 00:02:13 2008 0 x.x.x.x 521 /home3/FTP-protected/TFN/ixx/
GPSdetail_rpt_20080428_200525.txt b _ i r xxx ftp 0 * c
Tue Apr 29 00:03:40 2008 25x.x.x.x 4246252 /home4/FTP-protected/
DATAWORKS/1234/user_nameEUestimates_2000.zip b _ o r username ftp 0 *
c

use strict;
use warnings;
#Define LogFiles
my $dateroot=$ARGV[0]; # Value should be 2-digit month
my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
files sent to users
my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
uploads
my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is where
log users
my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
Completed Sessions
my $failedlog="failedlog_xferlog.$dateroot.csv";   # This is for
all Failures
my %loginsin;
my %completed;
my %failures;
my %incoming;
my %outgoing;

 #Time Measured
print "Started Processing Logfiles for $dateroot at " .
(localtime) ."\n\n";
 #Open Log File Dir to Read .log file(s)
opendir (DIR, ".") or die "$!";

#my @logfiles = grep {/xferlog\.$dateroot/,}  readdir DIR;
my @logfiles = grep {/$dateroot/,} readdir DIR;
close DIR;

   #Start Log Processing
foreach my $logfile (@logfiles) {
   print "Started Processing: $logfile at " . (localtime) ."\n";
   open(FH,"./$logfile") or die "$!";
   while ( my $lines =  ) {
 chomp($lines);
  my @fields = split / /, $lines; #This is where we look for the .
extensions from the file name
#   next if /^#/;
#next if /^(\s)*$/;
  #My Ftp Status Log Values
  my $TIME  =$fields[3]||'NULL';#fields[1],fields[2],fields[3];
  my $YEAR = $fields[4]||'NULL';
  my $IP = $fields[6]||'NULL';
  my $SIZE = $fields[7]||'NULL';#filesize
  my $FILE = $fields[8]||'NULL';#filename and path
  my $DIRECTION = $fields[11]||'NULL'; #Outgoing, Incoming
  my $USERNAME = $fields[13]||'NULL';
  my $STATUS= $fields[17]||'NULL';   #c = completed  i=incomplete
( my $MASKFILE = $FILE ) =~ tr/0-9/#/; #$cnt = tr/0-9//;# count
the digits in $_

  #FailuresThis is where we check for
failures
if ($DIRECTION eq "i" and $STATUS ne "c" ){$failures {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$IP;}
  #completed sessions
if ($STATUS =~ m "c" ){$completed {$USERNAME}   = $TIME.",".$YEAR.",".
$IP;}

   # incoming
if ($DIRECTION eq "i"  ){$incoming {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$SIZE.",".$IP;}
  #Outgoing  this is where we log all
outgoing xfers
if ($DIRECTION eq "o"){$outgoing {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$SIZE.",".$IP;}

   #Masked Options  with file
ex

Re: Debug Help Please

2008-07-08 Thread Andy
On Jul 7, 2:16 pm, [EMAIL PROTECTED] (Andy) wrote:
> On Jul 7, 11:53 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
>
>
>
> > Andy wrote:
>
> > > Funny how when you talk to different people you get different ways of
> > > looking at it.
>
> > > One of the Perl guys at my office. told me that I can use
> > > use strict;
> > > use warnings;
>
> > > but he said , he really doesn't because he wants the script to do what
> > > it needs to do...
>
> > Then he is a fool and should be disregarded. Perhaps he could post to this 
> > group
> > to explain himself?
>
> > > I have made corrections as you suggested.
> > >  I have included.
>
> > > use strict;
> > > use warnings;
>
> > > as well as
> > >  my $TIME  =$fields[3]
>
> > > However after that ,
> > > I still get zero output.
>
> > > Maybe I have this written .
>
> > Have you incorporated all the corrections that John posted in his first
> > response? Perhaps you should post your program in its current state so that 
> > we
> > can take another look.
>
> > Rob
>
> Thank you all for the patience.
>
> I have been doing some debugging...well as much of it as I can handle
> with no exp...
>
> This is the current code. I figured out with some help that My
> $Dateroot was trying to read
> incoming.xferlog.xferlog.csv.
>
> Eventually I want to run "perl andylog.pl and it will Parse all the
> xferlogs in the dir.
>
> Thus far with all your help I have it working...now for the tweaks.
>
> I have some lines longer than the other and I have to figure out how
> to skip those lines ...
>
> So now I have to figure out how to read them all even longer ones
> Tue Apr 29 00:02:13 2008 0 x.x.x.x 521 /home3/FTP-protected/TFN/ixx/
> GPSdetail_rpt_20080428_200525.txt b _ i r xxx ftp 0 * c
> Tue Apr 29 00:03:40 2008 25x.x.x.x 4246252 /home4/FTP-protected/
> DATAWORKS/1234/user_nameEUestimates_2000.zip b _ o r username ftp 0 *
> c
>
> use strict;
> use warnings;
> #Define LogFiles
> my $dateroot=$ARGV[0]; # Value should be 2-digit month
> my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
> files sent to users
> my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
> uploads
> my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is where
> log users
> my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
> Completed Sessions
> my $failedlog="failedlog_xferlog.$dateroot.csv";   # This is for
> all Failures
> my %loginsin;
> my %completed;
> my %failures;
> my %incoming;
> my %outgoing;
>
>  #Time Measured
> print "Started Processing Logfiles for $dateroot at " .
> (localtime) ."\n\n";
>  #Open Log File Dir to Read .log file(s)
> opendir (DIR, ".") or die "$!";
>
> #my @logfiles = grep {/xferlog\.$dateroot/,}  readdir DIR;
> my @logfiles = grep {/$dateroot/,} readdir DIR;
> close DIR;
>
>#Start Log Processing
> foreach my $logfile (@logfiles) {
>print "Started Processing: $logfile at " . (localtime) ."\n";
>open(FH,"./$logfile") or die "$!";
>while ( my $lines =  ) {
>  chomp($lines);
>   my @fields = split / /, $lines; #This is where we look for the .
> extensions from the file name
> #   next if /^#/;
> #next if /^(\s)*$/;
>   #My Ftp Status Log Values
>   my $TIME  =$fields[3]||'NULL';#fields[1],fields[2],fields[3];
>   my $YEAR = $fields[4]||'NULL';
>   my $IP = $fields[6]||'NULL';
>   my $SIZE = $fields[7]||'NULL';#filesize
>   my $FILE = $fields[8]||'NULL';#filename and path
>   my $DIRECTION = $fields[11]||'NULL'; #Outgoing, Incoming
>   my $USERNAME = $fields[13]||'NULL';
>   my $STATUS= $fields[17]||'NULL';   #c = completed  i=incomplete
> ( my $MASKFILE = $FILE ) =~ tr/0-9/#/; #$cnt = tr/0-9//;# count
> the digits in $_
>
>   #FailuresThis is where we check for
> failures
> if ($DIRECTION eq "i" and $STATUS ne "c" ){$failures {$USERNAME}   =
> $TIME.",".$YEAR.",".$FILE.",".$IP;}
>   #completed sessions
> if ($STATUS =~ m "c" ){$completed {$USERNAME}   = $TIME.",".$YEAR.",".
> $IP;}
>
># incoming
> if ($DIRECTION eq "i"  ){$incoming {$USERNAME}   = $TIME.",".$YEAR.",".
> $FILE.",".$SIZE.",".$IP;}
>   #Outgoing  this is where we log all
> outgoing xfers
> if ($DIRECTION eq "o"){$outgoing {$USERNAME}   = $TIME.",".$YEAR.",".
> $FILE.",".$SIZE.",".$IP;}
>
>#Masked Options  with file
> extensions
> #if ($DIRECTION eq "i" and $STATUS eq "c" ){$ {$USERNAME.",".
> $MASKFILE} = $FILE.",".$TIME.",".$YEAR.",".$IP.",".$STATUS;}
>}}
>
>close(FH);
>
> #}
> open(OUTPUT, '>', $incoming) or die("Could not open log file.");
> for my $key ( sort %incoming) { if ($incoming{$key}) { print OUTPUT
> "$key,$incoming{$key}\n";}}
> close(OUTPUT);
> open(OUTPUT, '>', $outgoing) or die("Could not open log file.");
> for my $key ( sort %outgoing) { if ($outgoing{$key}) { print 

Re: Debug Help Please

2008-07-08 Thread Andy
On Jul 7, 4:33 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> Andy wrote:
>
> > Funny how when you talk to different people you get different ways of
> > looking at it.
>
> Yes, that is how the world works.  In Perl there is the expression
> TIMTOWTDI (There Is More Than One Way To Do It) which means that you
> will probably get different opinions on "The Right Way" to do something
> in Perl.
>
> > One of the Perl guys at my office. told me that I can use
> > use strict;
> > use warnings;
>
> > but he said , he really doesn't because he wants the script to do what
> > it needs to do...
>
> That is a specious argument because you can disable specific strictures
> or warnings in local scope:
>
> $ perl -le'
> use strict;
> {   no strict "vars";
>  $x = 8;  # line 4}
>
> $y = 9;  # line 6
> '
> Global symbol "$y" requires explicit package name at -e line 6.
> Execution of -e aborted due to compilation errors.
>
> $ perl -le'
> use warnings;
> my $x;
> {   no warnings "uninitialized";
>  print "$x";  # line 5}
>
> print "$x";  # line 7
> '
>
> Use of uninitialized value in string at -e line 7.
>
> > I have made corrections as you suggested.
> >  I have included.
>
> > use strict;
> > use warnings;
>
> > as well as
> >  my $TIME  =$fields[3]
>
> > However after that ,
> > I still get zero output.
>
> > Maybe I have this written .
>
> OK, based on your original code and example data line:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> # Store the program name without the path, if any
> ( my $program = $0 ) =~ s!.*/!!s;
>
> # User should supply a valid month number
> my ( $dateroot ) = map sprintf( '%02d', $_ ), $ARGV[ 0 ] =~
> /\A([1-9]|1[0-2])\z/;
> defined $dateroot or die "usage: $program [month number]\n";
>
> # Define LogFiles
> my $outgoing = "outgoing_xferlog.$dateroot.csv";# This is
> for all files sent to users
> my $incoming = "incoming_xferlog.$dateroot.csv";# This is
> log for uploads
> my $loginsinlog  = "loginsinlog_xferlog.$dateroot.csv"; # This is
> where log users
> my $completedlog = "completedlog_xferlog.$dateroot.csv";# All
> Completed Sessions
> my $failedlog= "failedlog_xferlog.$dateroot.csv";   # This is
> for all Failures
>
> #Time Measured
> print "Started Processing Logfiles for $dateroot at ", scalar localtime,
> "\n\n";
> #Open Log File Dir to Read .log file(s)
> my @logfiles = do {
>  opendir my $DIR, '.' or die "Cannot open '.' $!";
>  grep /xferlog\.$dateroot/, readdir $DIR;
>  };
>
> #Start Log Processing
> my %failures;
> my %completedlog;
> my %incoming;
> my %outgoing;
> for my $logfile ( @logfiles ) {
>  print "Started Processing: $dateroot at ", scalar localtime, "\n";
>  open my $FH, '<', $logfile or die "Cannot open '$logfile' $!";
>  while ( <$FH> ) {
>  #My Ftp Status Log Values
>  next unless my ( $time, $year, $IP, $size, $name, $direction,
> $user, $status ) = /
>  \S+\s+\S+\s+\d+\s+
>  (\d\d:\d\d:\d\d)   # field  3 - time
>  \s+
>  (\d{4})# field  4 - year
>  \s+\S+\s+
>  ([\d.]+)   # field  6 - IP address
>  \s+
>  (\d+)  # field  7 - file size
>  \s+
>  (\S+)  # field  8 - file name and path
>  \s+\S+\s+\S+\s+
>  ([io]) # field 11 - Outgoing or Incoming
>  \s+\S+\s+
>  (\S+)  # field 13 - user name
>  \s+\S+\s+\S+\s+\S+\s+
>  ([ci]) # field 17 - c = completed  i =
> incomplete
>  /x;
>
>  ( my $maskfile = $name ) =~ tr/0-9/#/;
>
>  #FailuresThis is where we check for failures
>  if ( $status eq 'i' ) {
>  $failures{ $user } = "$time,$year,$name,$IP";
>  next;
>  }
>
>  #completed sessionsLast Login
>  $completedlog{ $user } = "$time,$year,$IP";
>
>  #Completed incoming
>  if ( $direction eq 'i' ) {
>  $incoming{ $user } = "$time,$year,$name,$size,$IP";
>
>  #Masked Options with file extensions will be added for
> later use
>  $completedlog{ "$user,$maskfile" } =
> "$name,$time,$year,$IP,$status";
>  }
>  #Outgoing  this is where we log all outgoing xfers
>  elsif ( $direction eq 'o' ) {
>  $outgoing{ $user } = "$time,$year,$name,$size,$IP";
>  }
>  }
>  }
>
> open my $OUT1, '>', $incoming or die "Could not open '$incoming' $!";
> open my $OUT2, '>', $failedlogor die "Could not open '$failedlog' $!";
> open my $OUT3, '>', $completedlog or die "Could not open '$completedlog'
> $!";
> for my $key ( sort keys %failures ) {
>  print $OUT1 "$k

Re: Debug Help Please

2008-07-07 Thread Andy
On Jul 7, 11:53 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> Andy wrote:
>
> > Funny how when you talk to different people you get different ways of
> > looking at it.
>
> > One of the Perl guys at my office. told me that I can use
> > use strict;
> > use warnings;
>
> > but he said , he really doesn't because he wants the script to do what
> > it needs to do...
>
> Then he is a fool and should be disregarded. Perhaps he could post to this 
> group
> to explain himself?
>
> > I have made corrections as you suggested.
> >  I have included.
>
> > use strict;
> > use warnings;
>
> > as well as
> >  my $TIME  =$fields[3]
>
> > However after that ,
> > I still get zero output.
>
> > Maybe I have this written .
>
> Have you incorporated all the corrections that John posted in his first
> response? Perhaps you should post your program in its current state so that we
> can take another look.
>
> Rob

Thank you all for the patience.

I have been doing some debugging...well as much of it as I can handle
with no exp...

This is the current code. I figured out with some help that My
$Dateroot was trying to read
incoming.xferlog.xferlog.csv.

Eventually I want to run "perl andylog.pl and it will Parse all the
xferlogs in the dir.

Thus far with all your help I have it working...now for the tweaks.

I have some lines longer than the other and I have to figure out how
to skip those lines ...

So now I have to figure out how to read them all even longer ones
Tue Apr 29 00:02:13 2008 0 x.x.x.x 521 /home3/FTP-protected/TFN/ixx/
GPSdetail_rpt_20080428_200525.txt b _ i r xxx ftp 0 * c
Tue Apr 29 00:03:40 2008 25x.x.x.x 4246252 /home4/FTP-protected/
DATAWORKS/1234/user_nameEUestimates_2000.zip b _ o r username ftp 0 *
c


use strict;
use warnings;
#Define LogFiles
my $dateroot=$ARGV[0]; # Value should be 2-digit month
my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
files sent to users
my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
uploads
my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is where
log users
my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
Completed Sessions
my $failedlog="failedlog_xferlog.$dateroot.csv";   # This is for
all Failures
my %loginsin;
my %completed;
my %failures;
my %incoming;
my %outgoing;

 #Time Measured
print "Started Processing Logfiles for $dateroot at " .
(localtime) ."\n\n";
 #Open Log File Dir to Read .log file(s)
opendir (DIR, ".") or die "$!";

#my @logfiles = grep {/xferlog\.$dateroot/,}  readdir DIR;
my @logfiles = grep {/$dateroot/,} readdir DIR;
close DIR;

   #Start Log Processing
foreach my $logfile (@logfiles) {
   print "Started Processing: $logfile at " . (localtime) ."\n";
   open(FH,"./$logfile") or die "$!";
   while ( my $lines =  ) {
 chomp($lines);
  my @fields = split / /, $lines; #This is where we look for the .
extensions from the file name
#   next if /^#/;
#next if /^(\s)*$/;
  #My Ftp Status Log Values
  my $TIME  =$fields[3]||'NULL';#fields[1],fields[2],fields[3];
  my $YEAR = $fields[4]||'NULL';
  my $IP = $fields[6]||'NULL';
  my $SIZE = $fields[7]||'NULL';#filesize
  my $FILE = $fields[8]||'NULL';#filename and path
  my $DIRECTION = $fields[11]||'NULL'; #Outgoing, Incoming
  my $USERNAME = $fields[13]||'NULL';
  my $STATUS= $fields[17]||'NULL';   #c = completed  i=incomplete
( my $MASKFILE = $FILE ) =~ tr/0-9/#/; #$cnt = tr/0-9//;# count
the digits in $_

  #FailuresThis is where we check for
failures
if ($DIRECTION eq "i" and $STATUS ne "c" ){$failures {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$IP;}
  #completed sessions
if ($STATUS =~ m "c" ){$completed {$USERNAME}   = $TIME.",".$YEAR.",".
$IP;}

   # incoming
if ($DIRECTION eq "i"  ){$incoming {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$SIZE.",".$IP;}
  #Outgoing  this is where we log all
outgoing xfers
if ($DIRECTION eq "o"){$outgoing {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$SIZE.",".$IP;}

   #Masked Options  with file
extensions
#if ($DIRECTION eq "i" and $STATUS eq "c" ){$ {$USERNAME.",".
$MASKFILE} = $FILE.",".$TIME.",".$YEAR.",".$IP.",".$STATUS;}
   }
}
   close(FH);

#}
open(OUTPUT, '>', $incoming) or die("Could not open log file.");
for my $key ( sort %incoming) { if ($incoming{$key}) { print OUTPUT
"$key,$incoming{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $outgoing) or die("Could not open log file.");
for my $key ( sort %outgoing) { if ($outgoing{$key}) { print OUTPUT
"$key,$outgoing{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $failedlog) or die("Could not open log file.");
for my $key ( sort %failures) { if ($failures{$key}) { print OUTPUT
"$key,failures{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $completedlog) or die("Could not open log file.");
for my $key ( so

Re: Debug Help Please

2008-07-07 Thread John W. Krahn

Andy wrote:


Funny how when you talk to different people you get different ways of
looking at it.


Yes, that is how the world works.  In Perl there is the expression 
TIMTOWTDI (There Is More Than One Way To Do It) which means that you 
will probably get different opinions on "The Right Way" to do something 
in Perl.




One of the Perl guys at my office. told me that I can use
use strict;
use warnings;

but he said , he really doesn't because he wants the script to do what
it needs to do...


That is a specious argument because you can disable specific strictures 
or warnings in local scope:


$ perl -le'
use strict;
{   no strict "vars";
$x = 8;  # line 4
}
$y = 9;  # line 6
'
Global symbol "$y" requires explicit package name at -e line 6.
Execution of -e aborted due to compilation errors.

$ perl -le'
use warnings;
my $x;
{   no warnings "uninitialized";
print "$x";  # line 5
}
print "$x";  # line 7
'

Use of uninitialized value in string at -e line 7.



I have made corrections as you suggested.
 I have included.

use strict;
use warnings;

as well as
 my $TIME  =$fields[3]

However after that ,
I still get zero output.

Maybe I have this written .


OK, based on your original code and example data line:

#!/usr/bin/perl
use warnings;
use strict;

# Store the program name without the path, if any
( my $program = $0 ) =~ s!.*/!!s;

# User should supply a valid month number
my ( $dateroot ) = map sprintf( '%02d', $_ ), $ARGV[ 0 ] =~ 
/\A([1-9]|1[0-2])\z/;

defined $dateroot or die "usage: $program [month number]\n";

# Define LogFiles
my $outgoing = "outgoing_xferlog.$dateroot.csv";# This is 
for all files sent to users
my $incoming = "incoming_xferlog.$dateroot.csv";# This is 
log for uploads
my $loginsinlog  = "loginsinlog_xferlog.$dateroot.csv"; # This is 
where log users
my $completedlog = "completedlog_xferlog.$dateroot.csv";# All 
Completed Sessions
my $failedlog= "failedlog_xferlog.$dateroot.csv";   # This is 
for all Failures


#Time Measured
print "Started Processing Logfiles for $dateroot at ", scalar localtime, 
"\n\n";

#Open Log File Dir to Read .log file(s)
my @logfiles = do {
opendir my $DIR, '.' or die "Cannot open '.' $!";
grep /xferlog\.$dateroot/, readdir $DIR;
};

#Start Log Processing
my %failures;
my %completedlog;
my %incoming;
my %outgoing;
for my $logfile ( @logfiles ) {
print "Started Processing: $dateroot at ", scalar localtime, "\n";
open my $FH, '<', $logfile or die "Cannot open '$logfile' $!";
while ( <$FH> ) {
#My Ftp Status Log Values
next unless my ( $time, $year, $IP, $size, $name, $direction, 
$user, $status ) = /

\S+\s+\S+\s+\d+\s+
(\d\d:\d\d:\d\d)   # field  3 - time
\s+
(\d{4})# field  4 - year
\s+\S+\s+
([\d.]+)   # field  6 - IP address
\s+
(\d+)  # field  7 - file size
\s+
(\S+)  # field  8 - file name and path
\s+\S+\s+\S+\s+
([io]) # field 11 - Outgoing or Incoming
\s+\S+\s+
(\S+)  # field 13 - user name
\s+\S+\s+\S+\s+\S+\s+
([ci]) # field 17 - c = completed  i = 
incomplete

/x;

( my $maskfile = $name ) =~ tr/0-9/#/;

#FailuresThis is where we check for failures
if ( $status eq 'i' ) {
$failures{ $user } = "$time,$year,$name,$IP";
next;
}

#completed sessionsLast Login
$completedlog{ $user } = "$time,$year,$IP";

#Completed incoming
if ( $direction eq 'i' ) {
$incoming{ $user } = "$time,$year,$name,$size,$IP";

#Masked Options with file extensions will be added for 
later use
$completedlog{ "$user,$maskfile" } = 
"$name,$time,$year,$IP,$status";

}
#Outgoing  this is where we log all outgoing xfers
elsif ( $direction eq 'o' ) {
$outgoing{ $user } = "$time,$year,$name,$size,$IP";
}
}
}

open my $OUT1, '>', $incoming or die "Could not open '$incoming' $!";
open my $OUT2, '>', $failedlogor die "Could not open '$failedlog' $!";
open my $OUT3, '>', $completedlog or die "Could not open '$completedlog' 
$!";

for my $key ( sort keys %failures ) {
print $OUT1 "$key,$failures{$key}\n";
print $OUT2 "$key,$failures{$key}\n";
print $OUT3 "$key,$failures{$key}\n";
}
close $OUT3;
close $OUT2;
close $OUT1;

print "\nFinished Processing Logfiles for $dateroot at ", scalar 
localtime, "\n\n";

print "This script took ", ( time() - $^T ) / 60, " minutes\n"

__END__



John
--
Perl isn't a toolbox, but a small machine shop where you
can spe

Re: Debug Help Please

2008-07-07 Thread Rob Dixon
Andy wrote:
> 
> Funny how when you talk to different people you get different ways of
> looking at it.
> 
> One of the Perl guys at my office. told me that I can use
> use strict;
> use warnings;
> 
> but he said , he really doesn't because he wants the script to do what
> it needs to do...

Then he is a fool and should be disregarded. Perhaps he could post to this group
to explain himself?

> I have made corrections as you suggested.
>  I have included.
> 
> use strict;
> use warnings;
> 
> as well as
>  my $TIME  =$fields[3]
> 
> However after that ,
> I still get zero output.
> 
> Maybe I have this written .

Have you incorporated all the corrections that John posted in his first
response? Perhaps you should post your program in its current state so that we
can take another look.

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Debug Help Please

2008-07-07 Thread Andy
On Jul 5, 9:54 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> Andy wrote:
>
> > Greets
>
> Hello,
>
> > Thanks for your earlier help, but I am still stuck.
>
> > I took your advice and I believe I put together the script as you
> > said.
>
> Except that you apparently haven't yet enabled the warnings and strict
> pragmas in your program to help you find your mistakes.
>
>
>
> > I decided to test with one output file in this case only the failed
> > log.
>
> > I get the creation of the csv but no data .
> > This is a line from the log I parse
> > Mon Apr 28 23:55:35 2008 0 X.X.X.X 5 /home3/FTP-protected/IBES/
> > siteseer/download.tst b _ o r USERNAME ftp 0 * c
>
> >  #Define LogFiles
> > my $dateroot = $ARGV[ 0 ]; # Value should be 2-digit month
> > my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
> > files sent to users
> > my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
> > uploads
> > my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is
> > wherelog users
> > my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
> > Completed Sessions
> > my $failedlog="failedlog_xferlog.$dateroot.csv";   # This is for
> > all Failures
> > my %loginsin;
> > my %completedlog;
> > my %failures;
> > my %incoming;
> > my %outgoing;
>
> >  #Time Measured
> >  print "Started Processing Logfiles for $dateroot at " .
> > (localtimetime) ."\n\n";
>
> 'localtimetime' is not a valid Perl function, that should be 'localtime
> time' or just 'localtime':
>
> print "Started Processing Logfiles for $dateroot at " . localtime . "\n\n";
>
> If you had enabled the warnings and strict pragmas then perl would have
> displayed a message to about that.  Please put these two lines at the
> top of your program to *help* you find these mistakes:
>
> use warnings;
> use strict;
>
>
>
> >   #Open Log File Dir to Read .log file(s)
> > opendir (DIR, ".") or die "$!";
> > my @logfiles = grep /xferlog\.$dateroot/, readdir DIR;
> > close DIR;
>
> >   #Start Log Processing
> >  foreach my $logfile (@logfiles) {
> > print "Started Processing: $dateroot at " . (localtime time) ."\n";
> > open(FH,"./$logfile") or die "$!";
> > while ( my $line =  ) {
> > chomp($line);
> > my @fields = split / /, $line; #This is where we look for the .
> > extensions
>
> > #My Ftp Status Log Values
> >  foreach ($line) {  #You mentioned why use this here? Is there a
> > better way?
>
> foreach loops over a list of items but you only have one scalar in that
> list.  foreach then aliases $_ to each item in that list in turn but you
> never use $_ inside the loop.  Therefore the foreach loop is superfluous
> and should be removed.
>
> >  print "HELLO";
> > my $TIME  = [3];
>
> That should be:
>
>  my $TIME  = fields[3];
>
>
>
> > my $YEAR = $fields[4];
> > my $IP = $fields[6];
> > my $SIZE = $fields[7];#filesize
> > my $FILE = $fields[8];#filename and path
> > my $DIRECTION = $fields[11]; #Outgoing, Incoming
> > my $USERNAME = $fields[13];
> > my $STATUS= $fields[17];   #c = completed
> > i=incomplete
> >   ( my $MASKFILE = $FILE ) =~ tr/0-9/#/;
>
> >  #FailuresThis is where we check for
> > failures
> > if ($STATUS eq "i" ){$failures {$USERNAME}   = $TIME.",".$YEAR.",".
> > $FILE.",".$IP;}
> >  #completed sessionsLast Login
> > if ($STATUS eq "c" ){$completedlog {$USERNAME}   = $TIME.",".
> > $YEAR.",".
> > $IP;}
>
> >  #Completed incoming
> > if ($DIRECTION eq "i" and $STATUS eq "c" ){$incoming {$USERNAME}   =
> > $TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}
> >  #Outgoing  this is where we log all
> > outgoing xfers
> > if ($DIRECTION eq "o" and $STATUS eq "c" ){$outgoing {$USERNAME}   =
> > $TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}
>
> >}
> >   }
> >   close(FH);
> > }
> >  open(OUTPUT, '>', $failedlog) or die("Could not open log file.");
> > foreach $key ( sort keys %failures ) {"$key,$failures{$key}\n";}
>
> You have a string in void context inside the loop.  If you had enabled
> the warnings and strict pragmas then perl would have displayed a message
> to that effect.  Please put these two lines at the top of your program
> to *help* you find these mistakes:
>
> use warnings;
> use strict;
>
> > close(OUTPUT);
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order.-- Larry Wall

Good Morning

Funny how when you talk to different people you get different ways of
looking at it.

One of the Perl guys at my office. told me that I can use
use strict;
use warnings;

but he said , he really doesn't because he wants the script to do what
it needs to do...

Re: Debug Help Please

2008-07-05 Thread John W. Krahn

Andy wrote:


Greets


Hello,


Thanks for your earlier help, but I am still stuck.

I took your advice and I believe I put together the script as you
said.


Except that you apparently haven't yet enabled the warnings and strict 
pragmas in your program to help you find your mistakes.




I decided to test with one output file in this case only the failed
log.

I get the creation of the csv but no data .
This is a line from the log I parse
Mon Apr 28 23:55:35 2008 0 X.X.X.X 5 /home3/FTP-protected/IBES/
siteseer/download.tst b _ o r USERNAME ftp 0 * c

 #Define LogFiles
my $dateroot = $ARGV[ 0 ]; # Value should be 2-digit month
my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
files sent to users
my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
uploads
my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is
wherelog users
my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
Completed Sessions
my $failedlog="failedlog_xferlog.$dateroot.csv";   # This is for
all Failures
my %loginsin;
my %completedlog;
my %failures;
my %incoming;
my %outgoing;



 #Time Measured
 print "Started Processing Logfiles for $dateroot at " .
(localtimetime) ."\n\n";


'localtimetime' is not a valid Perl function, that should be 'localtime 
time' or just 'localtime':


print "Started Processing Logfiles for $dateroot at " . localtime . "\n\n";

If you had enabled the warnings and strict pragmas then perl would have 
displayed a message to about that.  Please put these two lines at the 
top of your program to *help* you find these mistakes:


use warnings;
use strict;



  #Open Log File Dir to Read .log file(s)
opendir (DIR, ".") or die "$!";
my @logfiles = grep /xferlog\.$dateroot/, readdir DIR;
close DIR;

  #Start Log Processing
 foreach my $logfile (@logfiles) {
print "Started Processing: $dateroot at " . (localtime time) ."\n";
open(FH,"./$logfile") or die "$!";
while ( my $line =  ) {
chomp($line);
my @fields = split / /, $line; #This is where we look for the .
extensions



#My Ftp Status Log Values
 foreach ($line) {  #You mentioned why use this here? Is there a
better way?


foreach loops over a list of items but you only have one scalar in that 
list.  foreach then aliases $_ to each item in that list in turn but you 
never use $_ inside the loop.  Therefore the foreach loop is superfluous 
and should be removed.




 print "HELLO";
my $TIME  = [3];


That should be:

my $TIME  = fields[3];



my $YEAR = $fields[4];
my $IP = $fields[6];
my $SIZE = $fields[7];#filesize
my $FILE = $fields[8];#filename and path
my $DIRECTION = $fields[11]; #Outgoing, Incoming
my $USERNAME = $fields[13];
my $STATUS= $fields[17];   #c = completed
i=incomplete
  ( my $MASKFILE = $FILE ) =~ tr/0-9/#/;


 #FailuresThis is where we check for
failures
if ($STATUS eq "i" ){$failures {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$IP;}
 #completed sessionsLast Login
if ($STATUS eq "c" ){$completedlog {$USERNAME}   = $TIME.",".
$YEAR.",".
$IP;}

 #Completed incoming
if ($DIRECTION eq "i" and $STATUS eq "c" ){$incoming {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}
 #Outgoing  this is where we log all
outgoing xfers
if ($DIRECTION eq "o" and $STATUS eq "c" ){$outgoing {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}

   }
  }
  close(FH);
}
 open(OUTPUT, '>', $failedlog) or die("Could not open log file.");
foreach $key ( sort keys %failures ) {"$key,$failures{$key}\n";}


You have a string in void context inside the loop.  If you had enabled 
the warnings and strict pragmas then perl would have displayed a message 
to that effect.  Please put these two lines at the top of your program 
to *help* you find these mistakes:


use warnings;
use strict;



close(OUTPUT);



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Debug Help Please

2008-07-04 Thread Andy
On Jul 4, 1:16 am, [EMAIL PROTECTED] (John W. Krahn) wrote:
> Andy wrote:
> > Well Disregard the above script I made changes that I think were
> > needed, but I still have no output in the .csv files
>
> You still have some of the same mistakes that were in the program the
> last time you posted it.  Have you read my reply to your first posting yet?
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order.-- Larry Wall

I posted this after I realized that I made mistakes. Then Your
solution posted.

Thank you for yoru response, I will do as you say .


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Debug Help Please

2008-07-03 Thread John W. Krahn

Andy wrote:

Well Disregard the above script I made changes that I think were
needed, but I still have no output in the .csv files


You still have some of the same mistakes that were in the program the 
last time you posted it.  Have you read my reply to your first posting yet?



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Debug Help Please

2008-07-03 Thread Andy
Well Disregard the above script I made changes that I think were
needed, but I still have no output in the .csv files

#!/usr/bin/perl
#use strict;
#use warnings;
#Define LogFiles
my $dateroot="$ARGV[0]"; # Value should be 2-digit month
my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
files sent to users
my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
uploads
my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is where
log users
my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
Completed Sessions
my $failedlog="failedlog_xferlog.$dateroot.csv";   # This is for
all Failures
my %loginsin;
my %completed;
my %failures;
my %fields;
my %incoming;
my %outgoing;
my %logfiles;
 #Time Measured
print "Started Processing Logfiles for $dateroot at " . (localtime
time) ."\n\n";
 #Open Log File Dir to Read .log file(s)
opendir (DIR, ".") or die "$!";

my @logfiles = grep {/xferlog\.$dateroot.*/}  readdir (DIR);
close DIR;

   #Start Log Processing
foreach my $logfile (@logfile) {
   print "Started Processing: $dateroot at " . (localtime time) ."\n";
   open(FH,"./$logfile") or die "$!";
   while (){
my $line = $_;
chomp($line);
my @fields = split / /, $line; #This is where we look
for the . extensions from the file name

  #My Ftp Status Log Values
foreach ($line) {
my $TIME  =$fields[0],$fields[1],$fields[2],
$fields[3];
my $Year = $fields[4];
my $TRANSFER= $fields[5];#this value is in seconds
my $IP = $fields[6];
my $SIZE = $fields[7];#filesize
my $FILE = $fields[8];#filename and path
my $TYPE = $fields[9];#A= ascii B = binary
my $DIRECTION = $fields[11]; #Outgoing, Incoming
my $USERNAME = $fields[13];
my $STATUS= $fields[17];   #c = completed  i=
incomplete
  # my $MASKFILE = $FILE;
  #  my $MASKFILE =~ s/\d/#/g;

  #FailuresThis is where we check for
failures
if ($STATUS eq "i" ){$failures {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$IP;}
  #completed sessionsLast Login
if ($STATUS eq "c" ){$completed {$USERNAME}   = $TIME.",".$YEAR.",".
$IP;}

   #Completed incoming
if ($DIRECTION eq "i" and $STATUS eq "c" ){$incoming {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}
  #Outgoing  this is where we log all
outgoing xfers
if ($DIRECTION eq "o" and $STATUS eq "c" ){$outgoing {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}

   #Masked Options  with file
extensions
#if ($DIRECTION eq "i" and $STATUS eq "c" ){$completedlog
{$USERNAME.",".$MASKFILE} = $FILE.",".$TIME.",".$YEAR.",".$IP.",".
$STATUS;}
}
next;
   }
   close(FH);
}
open(OUTPUT, '>', $outgoing) or die("Could not open log file.");
for my $key ( sort %outgoing) { if ($outgoing{$key}) { print OUTPUT
"$key,$outgoing{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $incoming) or die("Could not open log file.");
for my $key ( sort %incoming) { if ($incoming{$key}) { print OUTPUT
"$key,$incoming{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $loginsinlog) or die("Could not open log file.");
for my $key ( sort %loginsin) { if ($loginsin{$key}) { print OUTPUT
"$key,$loginsin{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $failedlog) or die("Could not open log file.");
for my $key ( sort %failures) { if ($failures{$key}) { print OUTPUT
"$key,$failures{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $completedlog) or die("Could not open log file.");
for my $key ( sort %completed) { if ($completed{$key}) { print OUTPUT
"$key,$completed{$key}\n";}}
close(OUTPUT);
print "\nFinished Processing Logfiles for $dateroot at " . (localtime
time) ."\n\n";
print "This script took ". (time - $^T)/60 ." minutes \n"


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Debug Help Please

2008-07-03 Thread John W. Krahn

Andy wrote:

Greets


Hello,


I wrote this script to parse information from some log files. It Seems
to work , or look like it works.
In the end I get the log creation of .csv log files with no
information.

I am learning how to write this , I know there are tons of ways to do
this. But My Boss made a decision to keep all the scripts looking
similar,  so I have to keep the format the same.

What did I do wrong that there is no information in the log files?

#!/usr/bin/perl


The next two lines *should* be:

use warnings;
use strict;

They will *help* you find errors in your code.



#Define LogFiles
my $dateroot="$ARGV[0]"; # Value should be 2-digit month


perldoc -q "What.s wrong with always quoting .$vars.?"


my $dateroot = $ARGV[ 0 ]; # Value should be 2-digit month



my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
files sent to users
my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
uploads
my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is where
log users
my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
Completed Sessions
my $failedlog="failedlog_xferlog.$dateroot.csv";   # This is for
all Failures
my %loginsin;
my %completedlog;
my %failures;
my %fields;


%fields is never used so why are you creating it?

You also need to declare the %incoming and %outgoing hashes:

my %incoming;
my %outgoing;



 #Time Measured
print "Started Processing Logfiles for $dateroot at " . (localtime
time) ."\n\n";
 #Open Log File Dir to Read .log file(s)
opendir (DIR, ".") or die "$!";

my @logfiles = grep {/xferlog\.$dateroot.*/}  readdir (DIR);


The .* at the end is superfluous.  The {} braces create a scope that you 
don't need.


my @logfiles = grep /xferlog\.$dateroot/, readdir DIR;



close DIR;

   #Start Log Processing
foreach my $logfile (@logfile) {


The variable @logfile is empty, it should be @logfiles instead, which is 
why you get an empty output file.  If you had enabled the strict pragma 
then perl would have notified you of this mistake.




   print "Started Processing: $dateroot at " . (localtime time) ."\n";
   open(FH,"./$logfile") or die "$!";
   while (){
my $line = $_;


Why not just:

 while ( my $line =  ) {

Or why not just use the $_ variable instead?



chomp($line);
my @fields = split / /, $line; #This is where we look


Did you really *really* *REALLY* mean to split on a single space 
character?  Or do you not really understand how split works?




for the . extensions from the file name

  #My Ftp Status Log Values
foreach ($line) {


OMG *why* do you have a foreach loop here?



my $TIME  =$fields[0],[1],[2],[3];


That is the same as:

 my $TIME  = [3];

Which assigns an anonymous array reference to the variable $TIME with 
one element with the value of 3.


If you had enabled the warnings and strict pragmas then perl would have 
informed you of this mistake.





my $Year = $fields[4];


The variable $Year is not used anywhere else, perhaps you meant $YEAR 
instead.




my $TRANSFER= $fields[5];#this value is in seconds


The variable $TRANSFER is never used anywhere else.



my $IP = $fields[6];
my $SIZE = $fields[7];#filesize
my $FILE = $fields[8];#filename and path
my $TYPE = $fields[9];#A= ascii B = binary


The variable $TYPE is never used anywhere else.



my $DIRECTION = $fields[11]; #Outgoing, Incoming
my $USERNAME = $fields[13];
my $STATUS= $fields[17];   #c = completed  i=
incomplete
my $MASKFILE = $FILE;
my $MASKFILE =~ s/\d/#/g;


my creates an empty variable so that line makes no sense.  If you had 
enabled the warnings and strict pragmas perl would have notified you of 
this mistake.  You probably should have written:


   ( my $MASKFILE = $FILE ) =~ tr/0-9/#/;



  #FailuresThis is where we check for
failures
if ($STATUS eq "i" ){$failures {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$IP;}
  #completed sessionsLast Login
if ($STATUS eq "c" ){$completedlog {$USERNAME}   = $TIME.",".$YEAR.",".
$IP;}

   #Completed incoming
if ($DIRECTION eq "i" and $STATUS eq "c" ){$incoming {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}
  #Outgoing  this is where we log all
outgoing xfers
if ($DIRECTION eq "o" and $STATUS eq "c" ){$outgoing {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$SIZE.",".$IP;}

   #Masked Options  with file
extensions WIll be added for later use
#if ($DIRECTION eq "i" and $STATUS eq "c" ){$completedlog
{$USERNAME.",".$MASKFILE} = $FILE.",".$TIME.",".$YEAR.",".$IP.",".
$STATUS;}
  

RE: Debug help

2001-08-23 Thread Bob Showalter

> -Original Message-
> From: Scott Taylor [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 22, 2001 6:46 PM
> To: [EMAIL PROTECTED]
> Subject: Debug help
> 
> 
> Hi all,
> I snatched this guest book off some script site 

Be careful. A lot of that stuff on "script sites" is pure crapola.

> and it's 
> either gone now, 
> or I misplaced the bookmark, but anyhow, perhaps someone can 
> help me with 
> the syntax.  Something I changed at 3AM one morning now it 
> doesn't work 
> right

Use RCS, CVS, or something. Make backups.

> , I know the MySQL parameters are fine, it's something I 
> accidently 
> deleted in here.
> $success returns this value: DBI::st=HASH(0x81a8280) at the line 
> if($success != 1) ...

Well, $success is the return from prepare(), which is a statement
handle. Why would you compare a statement handle to a 1?

> can anyone point out my obvious mistake?

Calling the handle "$success" implies that you mean for this
variable to be the result of the execute() method.

Read the DBI docs to see what prepare() and execute() return.

Note that the return of prepare() is not checked. You might
want to do that, otherwise the execute() call will barf ungracefully.

> 
> sub insert_entry {
>  my ($dbh, $success, $name, $email, $website, $comments,$time);
> 
>  $dbh = DBI->connect("DBI:mysql:database=$serverDb;
>   
> host=$serverName;port=$serverPort",$serverUser,$serverPass);
>  $name = param("name");
>  $email = param("email");
>  $website = param("website");
>  $comments = param("comments");
>  $time = time;
>  $SQL = "INSERT INTO $serverTabl(name,email,website,comments,time)
>VALUES(?, ?, ?, ?, ?)", undef, $name, 
> $email,$website,$comments,$time;
>  $success = $dbh->prepare($SQL);
>  $success->execute;
>  $dbh->disconnect;
>  if($success != 1) {
>   return "$success Sorry, the database was unable to 
> add your entry.
>Please try again later."
>  } else {
>  return;
>  }
> }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]