For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2004 > Modules









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Modules
Shilpa Arvind

2004-04-27, 12:26 am

Hi,

I have a subroutine which is used by 2 programs. I want to make that
subroutine a module. The subroutine uses some variables which i have
declared in my main program. I am not able to pass those variable to my
module. The subroutine is given below: The variables
$base_files_used$exp_string and $base_files_to_remove$exp_string are
declared in my main function. How should i call those two variables in my
module? I have the same 2 variables declared in my other program which uses
different values. Any help will be greatly appreciated.

sub note_file_for_tarball {
if ( 2 != @_ ) {
die "Wrong number of arguments to note_file_for_tarball.
Dying at ";
}
my $filename = $_[0];
my $to_be_removed = $_[1];

my $file_log = "$base_files_used$exp_string";
my $remove_log = "$base_files_to_remove$exp_string";

open( FILE_USE_LOG, ">> $file_log" ) || die "Could not open
$file_log for writing. Died at ";
print FILE_USE_LOG "$filename\n";
close( FILE_USE_LOG ) || die "Could not close $file_log. Died at ";

if ( $to_be_removed ) {
open( FILES_TO_REMOVE, ">> $remove_log" ) || die "Could not
open $remove_log for writing. Died at ";
print FILES_TO_REMOVE "$filename\n";
close( FILES_TO_REMOVE ) || die "Could not close
$remove_log. Died at ";
}
}


Shilpa


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com