in reply to Doubt in Eval
#!/usr/bin/env perl use strict; use warnings; sub get_accounts { print $aa; } my $aa = 5; get_accounts();
Lesson to learn: pass parameters to functions, do not rely on lexical variables leaking into the function from an outer scope. (Globals are okay.) To help enforce this through coding style, always place subroutine definitions before the main part of the code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Doubt in Eval
by chromatic (Archbishop) on Feb 16, 2012 at 22:08 UTC | |
|
Re^2: Doubt in Eval
by Anonymous Monk on Feb 16, 2012 at 21:38 UTC | |
by zwon (Abbot) on Feb 17, 2012 at 03:38 UTC | |
by Anonymous Monk on Feb 17, 2012 at 03:45 UTC | |
by zwon (Abbot) on Feb 17, 2012 at 07:08 UTC | |
by tobyink (Canon) on Feb 17, 2012 at 13:49 UTC | |
by Anonymous Monk on Feb 17, 2012 at 13:55 UTC | |
|
Re^2: Doubt in Eval
by chrestomanci (Priest) on Feb 17, 2012 at 21:26 UTC |