On Jun 6, Bryan R Harris said:
>1. What is a sigil?
Consult your nearest dictionary. Sigil == symbol.
>2. I like to make little reference pages for myself, do these terms look
>right?
I'd suggest scouring perlreftut and perlref.
># GETTING POINTERS
Stop using the word "pointer" right now. Immediately. Post-haste. Perl
does not have pointers. It has references. They are different.
/* C code */
int nums[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
int *p = nums;
printf("*p = %d\n", *p); /* 1 */
p++;
printf("*p = %d\n", *p); /* 2 */
Compare with:
# Perl code
@nums = (1,2,4,8,16,32,64,128,256,512);
$p = \@nums;
print "\$p->[0] = $p->[0]\n"; # 1
print "\$p->[1] = $p->[1]\n"; # 2
Perl does not have iterative "thingy"s like C's pointers. You could make
a faux-pointer with an object, but why?
>\$mystring; # returns a pointer to mystring
>\@myarray; # returns a pointer to myarray
>\%myhash; # returns a pointer to myhash
s/pointer/reference/ for the rest of this article.
># FOLLOWING POINTERS
>
>${ $pointer }; # returns string pointed to by $pointer
> # $pointer can be replaced with anything
> # that returns a pointer as a scalar
s/string/scalar/. If $x = \20, then $$x returns 20. If $x = \\"bar",
then $$x returns a reference (to "bar") which is a scalar, but certainly
NOT a string.
>@{ $pointer }[0]; # returns first element (element zero)
> # of the array pointed to by $pointer
${ $reference }[0] is better. The @ should be a $ here.
>$pointer->[0]; # (same)
>
>%{ $pointer }{$somekey}; # returns hash value of hash pointed
> # to by $pointer, key $somekey
NO. The % should be a $.
># CREATING STRUCTURES
>
>[ @myarray $mystring ]; # returns a pointer to a new copy of
> # a new array containing @myarray with
> # $mystring at the end
Missing a comma.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]