in reply to Sub Params as references
That having been said, I suspect the issue is in your assignment (via ${shift()}). Since you wish to change the values of your references, I would make assignments through the reference itself. It appears that you're assigning the dereffed value of your stringrefs to scoped vars, not assigning local values to the referenence itself.
Strings are really easy to deref -- just add another $. I think your subroutine should probably look like this: (Line Numbers added)
A couple things to note:1:sub read_template 2:{ 3: my($file_name_ref,$lines_in_ref) = @_; 4: my $line_cnt = 0; 5: open (INPUT, "$$file_name_ref") || 6: die "Can't open $$file_name_ref as input:$!"; 7: while (<INPUT>) 8: { 9: $line_cnt++; 10: $$lines_in_ref .= $_; 11: } 12: close (INPUT); 13: return($line_cnt); 14:}
HTH!
| ÅßÅ×ÅßÅ
"It is a very mixed blessing to be brought back from the dead." -- Kurt Vonnegut |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sub Params as references
by Maclir (Curate) on Aug 14, 2002 at 03:57 UTC | |
by rinceWind (Monsignor) on Aug 14, 2002 at 09:51 UTC | |
by demerphq (Chancellor) on Aug 14, 2002 at 11:14 UTC |