"Uri Guttman" <u...@stemsystems.com> writes: >>>>>> "HP" == Harry Putnam <rea...@newsguy.com> writes: > > HP> A third sub function is called in the dispatch table ( N(@_); ) but > HP> the variables don't survive to be use there. > > there are no variables to survive in a sub, just passed arguments in @_ > > HP> The output from the script below: > HP> Shows 6 elements arrive in dispt($g, @ar) as @_. But when sub N(@_) > HP> is called, no variables arrive there. @_ is empty. When it seems like > HP> 5 elements should have arrived there > > well, it helps if you actually pass in arguments. @_ is NOT a global. > > HP> my $code = $dispt{$selection} || $dispt{'error'} ; > HP> $code->(); > > you aren't passing anything in to $code. you need to put something in > the () which then is set in the @_ of the called sub.
I'm catching on a little maybe... and rearranged things so that everything is passed at code->(HERE) But in that case I could as well use global variables instead. But even though I can work with that... I'm still not seeing why the values in @_ are not available at the call to N() inside like this: (incomplete code) func($val1,$val2); sub func { %h = ( N => sub { print N(@_#HERE) . "\n"; } ); } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/