> What should cause me to have to pass variables to  a subroutine through
> arguments?

One of the answers could be reusability and modularity. If you use
arguments, you can call this subroutine whenever you like and from different
programs too and not be dependent on the main program to define global vars.


imagine, I need to open 100 files. So, I write a subroutine for openning a
file:

sub open_file {
$file_name = $_[0];

...
}


then I use one subroutine for openning 100 files, by prviding the file name
as an argument.

In your practise, I would have to write 100 subroutines, each of then
referencing different global variable with the name of the file to be
opened.

sub open_file1 {
$file_name = $my_global_var1;

...
}

sub open_file2 {
$file_name = $my_global_var2;

...
}

Hope it helps,
Albena


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

Reply via email to