Re: Need a little help with a sub.

2004-10-14 Thread Wiggins d Anconia
> I am calling a sub with:
> 
> &Navigate(%modules, %settings);
>

Drop the C<&> until you know what it is for. 
 
> And reading it like:
> 
> sub Navigate {
> (%modules, %settings) = @_;
> 

Perl flattens lists automagically, so when it sees your C<%modules,
%settings> it flattens it to one list of key value pairs, or actually
just an ordered list of values. Conveniently when you are assigning a
list to a hash Perl is smart enough to switch the ordered list back into
key/value pairs, however the problem and the reason the above won't
work, is that Perl keeps gobbling until the end. So your two lists, get
flattened into 1, and remain flattened with all of the values going into
%modules.  This is most commonly avoided by passing references to the
two lists into the sub, then you can dereference them back into
lists/hashes if you like. So,

Navigate(\%modules, \%settings);

sub Navigate {
  my ($modules, $settings) = @_;
  my %modules = %$modules;
  my %settings = %$settings;
  ...
}

Though you should consider just leaving them references and working on
them directly with the C<< -> >> operator.

> Only the first sub gets passed...
> 
> Been a while and I cant figure out what I am doing wrong.  To tired to 
> screw arround with it so I would love if some kind soul could point out 
> what I am forgetting.  Thanks!
> 
> aNc
>

For much more on references check out,

perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc

And/or the Learning PORM book from ORA, 

http://www.oreilly.com/catalog/lrnperlorm/

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Need a little help with a sub.

2004-10-14 Thread Sean Davis
If you have two hashes, you are probably better off passing by 
reference, otherwise the first hash will slurp up the second hash on 
the [EMAIL PROTECTED]

Something like
&Navigate(\%modules,\%settings);
sub Navigate {
my ($module_ref,$settings_ref)[EMAIL PROTECTED];
Sean
On Oct 14, 2004, at 4:55 PM, Andre Cameron wrote:
I am calling a sub with:
&Navigate(%modules, %settings);
And reading it like:
sub Navigate {
   (%modules, %settings) = @_;
Only the first sub gets passed...
Been a while and I cant figure out what I am doing wrong.  To tired to 
screw arround with it so I would love if some kind soul could point 
out what I am forgetting.  Thanks!

aNc
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Need a little help with a sub.

2004-10-14 Thread Andre Cameron

&Navigate(%modules, %settings);
And reading it like:
sub Navigate {
   (%modules, %settings) = @_;
Only the first sub gets passed...
See how tired I am?  I ment hash, only the first HASH get passed LOL.
aNc
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Need a little help with a sub.

2004-10-14 Thread Andre Cameron
I am calling a sub with:
&Navigate(%modules, %settings);
And reading it like:
sub Navigate {
   (%modules, %settings) = @_;
Only the first sub gets passed...
Been a while and I cant figure out what I am doing wrong.  To tired to 
screw arround with it so I would love if some kind soul could point out 
what I am forgetting.  Thanks!

aNc
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]