I am trying to learn Perl. I have gotten to the section on lists, arrays and hashes. I read through the tutorials, perlman and perldsc. I want to make sure I understand the following snippet from one of your online tutorials. I've changed some of the values in the pairs to make my questions easier to ask.
$rec = {
TEXT => "Fred loves Ethel",
SEQUENCE => [ 13, 27, 47, 98 ],
LOOKUP => { cars => 'Buick', dog = 'hound' },
THATCODE => \&some_function,
THISCODE => sub { $_[0] ** $_[1] },
HANDLE => \*STDOUT,
};
print $rec->{TEXT};
print $rec->{SEQUENCE}[0];
print $rec->{LOOKUP}{"dog"};
This is what I think the output would look like (I don't have access to a programming environment at the moment; otherwise, I'd just type stuff in and see what happens):
Fred loves Ethel
13
hound
Am I correct about the output of these print statements?
Thank you for your help as I read through these tutorials to learn Perl.
Raye Ann Whitlow
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.