Hi all
Hello,
I am trying to learn perl. I am using perl afs module to administer our
afs cell. my problem is, the attached script is forking a new process
and is not releasing the memory as iam new to programming I am pretty
sure i am doing some simple mistake I would be really thankfull if one
of the expert can have a look at my script.
The only place in your code that forks is this line:
my @list = `/bin/cat /home/bobby/scripts/duplicate/test`; foreach ( @list )
And you can code that without forking like this:
my $file = '/home/bobby/scripts/duplicate/test'; open FILE, $file or die "Cannot open $file: $!"; my @list = <FILE>; foreach ( @list )
If your program is running out of memory then you should write that like this:
my $file = '/home/bobby/scripts/duplicate/test'; open FILE, $file or die "Cannot open $file: $!";
while ( <FILE> )
See:
perldoc -q "How can I make my Perl program take less memory"
Also note the section "Avoid unnecessary quotes and stringification".
If you want to learn more about perl's memory usage read the section "Debugging Perl memory usage" in this document:
perldoc perldebguts
Also, one more comment (although I could make more :-).
my $afspath = "/afs/.ec.auckland.ac.nz/users/".(split //)[0]."/".(split //)[1]."/$entry";
You are using split() to do something that you could do more efficiently with substr() or unpack():
my $afspath = '/afs/.ec.auckland.ac.nz/users/'.substr($entry,0,1).'/'.substr($entry,1,1)."/$entry";
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>