> 
> --- Wiggins d Anconia <[EMAIL PROTECTED]> wrote:
> [snip]
> [snip]
> > In the above line, as the error suggests 'keys' must take a hash as its
> > argument, $printers{jobs} is a scalar, so essentially you need to
> > dereference its value back into a hash, ending up with,
> > 
> > foreach my $keys (keys %{ $printers{jobs} }) {
> [snip]
> 
> Was that! Every time a hash reference is returned i need to derefence!
Oh! god! 
> Is this kind of reference like the C pointer, or something like this?
> 

You only have to dereference if you are trying to do something to the
structure in aggregate, aka you have to supply a hash, such as is the
case for 'keys', 'values', and 'each'.  If you want to access a single
value from the nested hash, you can access it directly using the little
arrow syntax,

$printers->{jobs}->{4};

For instance would access the value with key '4' in the jobs hash of the
printers hash.

References are similar to C's pointers, more and less powerful in most
of the same ways everything else is in Perl as compared to C. The key
big one that I have heard of, is that there is no pointer (reference)
arithmetic in Perl as in C.  As I am not a C guy this is where my
elaboration ends, if you have more specific pointer/ref questions be
sure to ask, someone with more C experience will surely answer. 

For much more on refs check out,

perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc

<snip>

And the excellent Learning Perl Objs, Refs, and Mods from ORA.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to