Rance Hall schreef:
> I was printing the array in debug mode, but not in a way that would
> indicate that the values where in separate elements.
{ local ($", $\) = ("\n", "\n");
print "@ary";
}
> I was also printing the "count" of array elements and that apparently
> is also wrong, I was getting 1 when I should have got >1.
Maybe you printed something else?
> The doc I read said that there is a special variable called
> #$arrayname that has the count of array elements.
ITYM: $#ary (you swapped $ and #). It is the index number of the last
element. Depends on the value of $[.
perlvar:
--------
@ARGV The array @ARGV contains the command-line arguments intended
for the script. $#ARGV is generally the number of arguments
minus one, because $ARGV[0] is the first argument, not the pro-
gram's command name itself. See $0 for the command name.
$[ The index of the first element in an array, and of the first
character in a substring. Default is 0, but you could theoret-
ically set it to 1 to make Perl behave more like awk (or For-
tran) when subscripting and when evaluating the index() and
substr() functions. (Mnemonic: [ begins subscripts.)
As of release 5 of Perl, assignment to $[ is treated as a com-
piler directive, and cannot influence the behavior of any other
file. (That's why you can only assign compile-time constants
to it.) Its use is highly discouraged.
Note that, unlike other compile-time directives (such as
strict), assignment to $[ can be seen from outer lexical scopes
in the same file. However, you can use local() on it to
strictly bound its value to a lexical block.
> But this isn't correct, so how do you return the count of array
> elements?
scalar(@ary)
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>