The problem is likely in your calling routine. Since $_ is a global, using it in any non-local context (like a loop variable in a loop that calls a subroutine) can be hazardous. You could fix your code by creating a local copy:
sub case_f { local $_ = catfile( $TOP_DIR, $_[0], $_[1] ); print "The path is $_ "; $_ }
To answer the more general question addressed by your subject line, you can find many details in perlvar. Note that they cover exactly what I said above in the intro to that piece of documentation.
|