J
Joza
How to make 2 dimensinal aray in Perl $mat(x,y)?
Thanks
Thanks
Joza said:How to make 2 dimensinal aray in Perl $mat(x,y)?
tim said:Joza wrote:
Hello
The syntax is like so:
$mat[x][y]
where x and y are >= 0
tim said:Joza wrote:
[top posting corrected, please don't do that]
Hello
The syntax is like so:
$mat[x][y]
That's not Perl, unless x and y are predefined functions, constants
for example. Also, your syntax is already a simplification. The
correct syntax is
$mat[ $x]->[ $y]
Strictly speaking, even that is a simplification. The basic syntax is
${ $mat[ $x] }[ $y]
where x and y are >= 0
Wrong. Perl allows access through negative indices.
Anno
Michele said:[snip full quoted content]sure, i realise that x and y aren't proper perl variables, i just used
them because Joza did in his post!
didn't know about the negative array indices though - thanks for that!
(e-mail address removed)-berlin.de wrote:
Thank you in advance for not top-posting next time! You won't, will
you?!?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
tim said:yup! sorry about before....
tim said:sorry about before....
Michele said:[snip full quoted content]sure, i realise that x and y aren't proper perl variables, i just used
them because Joza did in his post!
didn't know about the negative array indices though - thanks for that!
(e-mail address removed)-berlin.de wrote:
Thank you in advance for not top-posting next time! You won't, will
you?!?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Tad said:No you're not.
So long!
tim said:Joza wrote:
[top posting corrected, please don't do that]
Hello
The syntax is like so:
$mat[x][y]
That's not Perl, unless x and y are predefined functions, constants
for example. Also, your syntax is already a simplification.
The correct syntax is
$mat[ $x]->[ $y]
Strictly speaking, even that is a simplification. The basic syntax is
${ $mat[ $x] }[ $y]
Ala Qumsieh said:tim said:Joza wrote:
[top posting corrected, please don't do that]
How to make 2 dimensinal aray in Perl $mat(x,y)?
ThanksHello
The syntax is like so:
$mat[x][y]
That's not Perl, unless x and y are predefined functions, constants
for example. Also, your syntax is already a simplification.
Yes, but besides the fact that x and y should have been $x and $y, his
syntax was correct.
The correct syntax is
$mat[ $x]->[ $y]
Perl allows you to drop the arrow between indices, so this is not any more
correct than the $mat[$x][$y] syntax.
Strictly speaking, even that is a simplification. The basic syntax is
${ $mat[ $x] }[ $y]
Now, you are just showing off. I don't see what advantage pointing this out
has, except intimidating the OP and confusing him/her even more with
unnecessary information.
Knowing how the arrow notation relates to the general de-referencing
syntax isn't entirely useless.
The answer I was replying to was way too pat. I gave an extra complete
one in contrast. Neither did I intend to confuse anyone, nor to show off
(what, really?).
Ala Qumsieh said:I never said it was useless.
But you made it sound like it's more correct
than dropping the arrow, which I disagree with. TMTOWTDI, and all of the
ways are equally correct.
People don't need to know the internals of Perl to use it, just like people
don't need to know the internals of combustion engines to drive cars.
The answer I was replying to was way too pat. I gave an extra complete
one in contrast. Neither did I intend to confuse anyone, nor to show off
(what, really?).
and I didn't intend to offend. But imagine what the OP, who's obviously a
Perl newbie, would think after reading that $mat[$x][$y] is better written
as $mat[$x]->[$y], which is better written as ${ $mat[ $x] }[ $y].
My point is that an answer should be on the same level as the question
itself. If you want to give more information, then you should at least
point to docs that go into more depth about the subject.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.