> I know how to create / use references for perl. But would why would you
> use it.

Perl uses references for multidimensional/complex datastructures.  Also
used when doing OO in perl.

> And I think more importantly when.

Whenever appropriate.  :)  I probably make the greatest use of references
when working with datastructures.  I presume you know what {} and [] do.

An example:  Imagine you are working on a portion of a multi-dim.
datastructure.  Instead of:

$data{really}{deep}{hash}{elem1} = "First element";
$data{really}{deep}{hash}{elem2} = "Second element";
$data{really}{deep}{hash}{elem3} = "Third element";

You can write:

my $portion = $data{really}{deep}{hash};
$portion->{elem1} = "First element";
$portion->{elem2} = "Second element";
$portion->{elem3} = "Third element";

(Assuming $data{really}{deep}{hash} is a hash reference)

This will speed things up, and perhaps make code more readable.

I'll leave you to read up on how Perl does OO... not pretty but an
interesting and powerful approach.

Jonathan Paton

-- 
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,

-- 
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