I don't understand the problem. You made an error you got bitten. It's simple. You shouldn't (in any language) run a function that uses a variable and define the variable only later. It doesn't make any reason. It's like trying to get child welfare and having the child only a year later and complaining that the government won't pay for my child welfare before I had the kid.
Beyond that, you're defining the subroutine at the end, which exposes it to @_. I seriously don't understand why you're considering it a problem. You're simply doing something wrong. Two things actually. On Fri, Mar 6, 2009 at 9:41 AM, Gaal Yahas <[email protected]> wrote: > > Another is near the top of the file to say: > > main() if !caller; > sub main { > # ... > exit 0; > } > > On Fri, Mar 6, 2009 at 9:35 AM, Yitzchak Scott-Thoennes > <[email protected]> wrote: > > On Thu, March 5, 2009 1:12 pm, Shlomi Fish wrote: > >> my $filename = "hello.txt"; > >> > >> sub print_filename { > >> print $filename, "\n"; > >> } > > > > One thing you can do is to do the initialization at compile time: > > > > my $filename; > > BEGIN { $filename = "hello.txt" } > > > > > > _______________________________________________ > > Perl mailing list > > [email protected] > > http://perl.org.il/mailman/listinfo/perl > > > > > > -- > Gaal Yahas <[email protected]> > http://gaal.livejournal.com/ > _______________________________________________ > Perl mailing list > [email protected] > http://perl.org.il/mailman/listinfo/perl _______________________________________________ Perl mailing list [email protected] http://perl.org.il/mailman/listinfo/perl
