in reply to Can you explain me the output of this programme. especially in the subroutine func2
Bug 1: use strict; is missing. It'll show some encapsulation errors (i.e. a few missing mys).
Bug 2: use warnings; is missing. It'll show Bug 3.
Bug 3: func2 is declared after a call to it, so the prototype is ignored for that call.
Bug 4: You're using prototypes. Don't.
Bug 5: You modified $, without localizing it. (local $, = "...";)
use strict; use warnings; sub func1 { my $nums = shift; print("func1: ", join(', ', @$nums), "\n"); func2($nums); } sub func2 { my $nums = shift; print("func2: ", join(', ', @$nums), "\n"); } my @nums = (10,400,2,7,20,40,23,100,2); print("main: ", join(', ', @nums), "\n"); func1(\@nums);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can you explain me the output of this programme. especially in the subroutine func2
by sanketkathalkar (Initiate) on Nov 27, 2007 at 09:11 UTC | |
|
Re^2: Can you explain me the output of this programme. especially in the subroutine func2
by atemon (Chaplain) on Nov 26, 2007 at 16:18 UTC | |
by ikegami (Patriarch) on Nov 26, 2007 at 16:45 UTC | |
by cdarke (Prior) on Nov 26, 2007 at 16:47 UTC | |
by chromatic (Archbishop) on Nov 26, 2007 at 19:33 UTC |