S
sgarfunkle
I've been placing 'use' statements as close as possible to the actual
invocation of the module's subroutines, sometimes even placing them in
a loop:
#Hypothetical code...
while (<>) {
if (/^new_student\t(.*)$/) {
use Student;
my $student = new Student($1);
}
}
The goal is to ensure that if I someday take that code out, the use
statement is taken out as well. Is this a safe, efficient thing to do?
As far as I can tell, the use statement is processed only once, at
compile time.
I haven't been following this placement philosophy with 'my' thus far;
I've been placing a single 'my' at the top of subroutines with all the
variables I want to use within it. As you can see from the above code,
though, I'd like to start placing the declaration closer to the
instantiation, even if it means going into the middle of a loop.
Again, is this a safe, efficient thing to do?
Why does Java force all class imports to be at the top of a file,
anyway? Are the reasons philosophical, or purely technical?
invocation of the module's subroutines, sometimes even placing them in
a loop:
#Hypothetical code...
while (<>) {
if (/^new_student\t(.*)$/) {
use Student;
my $student = new Student($1);
}
}
The goal is to ensure that if I someday take that code out, the use
statement is taken out as well. Is this a safe, efficient thing to do?
As far as I can tell, the use statement is processed only once, at
compile time.
I haven't been following this placement philosophy with 'my' thus far;
I've been placing a single 'my' at the top of subroutines with all the
variables I want to use within it. As you can see from the above code,
though, I'd like to start placing the declaration closer to the
instantiation, even if it means going into the middle of a loop.
Again, is this a safe, efficient thing to do?
Why does Java force all class imports to be at the top of a file,
anyway? Are the reasons philosophical, or purely technical?