Problem when use split

From: John Doe (axam_at_vcable.net)
Date: 04/29/04


To: beginners@perl.org
Date: Thu, 29 Apr 2004 14:44:56 +0300

Hello all,
i write script that open and read file but i have problem.
First, here are a script:

----
#!/usr/bin/perl
use DBI;
my $dbuser = "xxx";
my $dbpass = "xxx";
my $db = "xxx";
my $u_dbuser = "xxx";
my $u_dbpass = "xxx";
my $u_db = "xxx";
my $sth = "";
my $dbh = "";
my $result = "";
my $sql = "";
my $tree = "/mnt/ftp/ftp1/users/";
my $user = "";
my $filequota = ".ftpquota"; # file contain record format 0 0
my $temp = "";
$sql = "SELECT username FROM tbl_users";
$dbh = DBI->connect("DBI:mysql:$db", $dbuser, $dbpass) || die "MySQL is
down\n";
$sth = $dbh->prepare($sql);
$sth->execute;
$dbhnew = DBI->connect("DBI:mysql:$u_db", $u_dbuser, $u_dbpass) || die
"MySQL is down\n";
while(my @rows = $sth->fetchrow_array) {
  $user = $rows[0];
  $fulltree = $tree . $user . "/" . $filequota;
  $files = 0;
  $quotause = 0;
  if (-e $fulltree) { # check to see if file exist
    open(FILE, "$fulltree");
    my @f = <FILE>;
    close(FILE);
    $temp = $f[0];
    ($files, $quotause) = split(/ /,$temp); # line 39
  }
  $sqlnew = "UPDATE tbl_users SET files='$files', quotause='$quotause' WHERE
username='$user'"; # line 41
  $sthnew = $dbhnew->prepare($sqlnew);
  $sthnew->execute;
}
$dbhnew->disconnect;
$dbh->disconnect;
----
When i run script i recive error:
# ./check-size.pl
: bad interpreter: No such file or directory
When i run perl with option -W say:
# perl -W check-size.pl
Use of uninitialized value in split at check-size.pl line 39.
Use of uninitialized value in concatenation (.) or string at check-size.pl
line 41.
Use of uninitialized value in concatenation (.) or string at check-size.pl
line 41.
Use of uninitialized value in split at check-size.pl line 39.
Use of uninitialized value in concatenation (.) or string at check-size.pl
line 41.
Use of uninitialized value in concatenation (.) or string at check-size.pl
line 41.
Any body can say me where is my error ?
Regards,
Condor


Relevant Pages

  • Re: Rename File Using Strring Found in File?
    ... OK, thanks, but the script does not seem to rename the files. ... You can set the working directory from within your Perl ... match for the "Citation:" etc string. ... The Perl Language and the Regular Expression Language are different ...
    (comp.lang.perl.misc)
  • my script crashes when I try to rename the file!
    ... OK, thanks, but the script does not seem to rename the files. ... You can set the working directory from within your Perl ... # sleep 1; ... to the string in this particular file that I want to match. ...
    (perl.beginners)
  • Re: Perl script to extract data from webpage? (knucklehead newbie).
    ... Your $& is a special perl variable that represents the string matched by ... the last successful pattern match...which in the case of your example ... I have this running now using a script I found elsewhere, ...
    (comp.lang.perl)
  • Re: How to pass string in command line argument.
    ... Perl Pra wrote: ... i have perl script that searches given string (the string should be passed ... The string should be sent to the script with double quotes attached to it ...
    (perl.beginners)
  • Re: Simple regex problem has me baffled
    ... I am writing a script to analyse a log file. ... Each pair of Request and Response calls have a unique ... Use of uninitialized value in concatenation or string at ./magic.pl ...
    (perl.beginners)