[ale] "use of uninitialized value" error in Perl program ?

Courtney Thomas ccthomas at joimail.com
Tue Dec 28 15:06:28 EST 2004


I don't know Perl at all, but am trying to write a small program to..... 
aggregate files from one dir to a second directory for the purpose of 
burning a CD, so the block of files size moved to the new dir will be 
~650MB.

I am getting the error "use of uninitialized value" in line 29.

I include the source as an attachment.

I'm assuming coding subroutines and calling them with the necessary 
variables would work, but am hoping for something quicker and certainly 
dirtier. I'm not interested in being a Perl programmer, rather burning 
some CDs and have merely shot in the dark hoping for a hit, and have 
failed, of course   :-)

But, hopefully a competent programmer can take these scattered bones and 
quickly suggest a more painless remedy than learning Perl, for which I 
don't have time.

Appreciatively,
Courtney
-- 
s/v Mutiny
Rhodes Bounty II
lying Oriental, NC
WDB5619
-------------- next part --------------
#!/usr/bin/perl -w
# The purpose of this program is to assemble an optimally sized block
# [prescribed] of files for burning on a RomBurner, by traversing a 
# prescribed directory and sequentially moving files to another 
# prescribed directory until the prescribed block size is assembled 
# in the newly filled directory.
#
use File::Copy;
use File::stat;
use FileHandle;
use DirHandle;
$file="";	#1st file in source dir
$dir="";	#source dir
$mvdir="";	#new aggregated dir
$size=0;	#source file size
$chunk=0;	#file block size to be burned
$counter=0;	#cumulative total block size in aggregated dir
print ("Dir from which to Copy Files ?\n");
chomp ($dir=<STDIN>);
print ("Dir to which Files are Copied ?\n");
chomp ($mvdir=<STDIN>);
print ("What size [in bytes] File Block is to be Assembled ?\n");
chomp ($chunk=<STDIN>);
$dh=new DirHandle $dir;
opendir $dh, $dir; 
while($counter < $chunk)		{
	readdir($dir);
	($size)=(stat("$dir/$file"))[7];
	$counter = $counter + $size;
	if ($counter<$chunk)		{
		copy "$file","$mvdir/$file";
		unlink "$dir/$file";
	}
	else				{	
		print ("The cut-point is $file/$dir \n");
		closedir $dh;
	}
}



More information about the Ale mailing list