I think the next world for me to conquer in Perl is references; I really seem to struggle with the concept and the use.
I've been reading the perldoc reftut and the concept still escapes me.
What I am understanding is that when you pass a reference to a function, you're not passing a copy of the referant but the referant itself (I think, like I said I don't get references too well). With the code I'm enclosing below, how could I play around with the concept of changing something via the use of a reference and a function and then see the results of the change in the main block of data.
#!/usr/bin/perl -w use strict; my %horoscopes = ( 'homer' => 'pisces', 'marge' => 'sagitarius', 'bart' => 'cancer', 'libra' => 'libra', ); my $reference = \%horoscopes; capitalize($reference); sub capitalize { foreach (keys(%{$reference})) { tr/[a-z]/[A-Z]/; } }
In reply to pass by reference by bivouac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |