in reply to Sub Params as references
you are copying your dereferenced references into new local variables, which does not update the variables in the caller. Try insteadmy $file_name = ${shift()}; my $lines_in = ${shift()};
This approach keeps the references and updates the caller's variables.sub read_template { my $file_name = shift; my $lines_in = shift; my $line_cnt = 0; if (!open (INPUT, "< $$file_name")) { die "Can't open $file_name as input."; } else { while (<INPUT>) { $line_cnt++; $$lines_in .= $_; } close (INPUT); } return($line_cnt); }
-Mark
|
|---|