I am not expert but I do know the fallowing.

Purl is like driving a car with automatic gear shift. Where other languages 
like C are like driving a car with a stick shift.
It is not necessary to use a My Local or Var statement to define a variable, 
you can make them on the fly with out them. But it is advisable to pre define 
them up front to avoid any surprises like running out of memory. It is 
considered good practice to use the stick and warnings at the start of your 
code like this:

 #!/usr/bin/perl --

use strict;
use warnings;

Witch will stop running you code when you get to the print "non-existent value: 
$aList[0][0]\n"; in your code. and thus make you set everything up front of 
your program and your sub routines. Personally I hate developing with strict 
on, it can be frustrating. But I have discovered that if I do the development 
with strick off, then switch it back on just as I'm finishing up and run the 
program (and watch is crash), I can use the error log to tell all the variable 
I need to be define. Most programs will probably consider this not a 
professional way to go about it. But it's my sneaky trick to get the computer 
to do some of the work for me.

An arrow with 2 indexes like your $aList[0][[0] in most other languages is 
considered a multi dimensional arrow having a sort of X,Y axis. Grate when 
doing graphics but I don't think that was what you wanted. To access different 
steps in your arrow, you just increment the index such as $aList[0], $aList[1], 
$aList[2]. ect but think you probably already know this. 

The Push command is usually used like this:
Push (@aList, "First") (with the parenthesis arround everything that the 
command is going to be dealing with) to add just one to the array.. You can 
push all of anther array to your array with Push (@aList, @blist). So I am 
shore there is a way to push mufti values to an array with push, if I could 
only remember the details on it. 

One command you might find really useful in you research is the exists command

if (exists $aList[0][0]) {print "Yes I do exist so 
aList[0][0]=".$aList[0][0]."\n"};

The exists command let you check that something is there with out creating it. 
Because if you try to print it like you did in your second example. Purl will 
make it just so you can see that it's empty, I know that don't seem to make 
much sense. But the exists command will leave your arrays and hashes alone and 
just give you a true or false if there exist or not. Also may I point out that 
I usually can't got arrows and defiantly not hashes to print out inside of 
quotes so if you just brake out of them for a moment, hence my example above 
"=".$aList[0][0]."\n". where I brake out of the text with a quote, glued it 
with a period and add the variable that I want to print out and then glued it 
again with anther period just before going back in with a quote to continue 
printing the text and cartridge return. 

And that I hope will give you some more tools for your creation. or should I 
say your Frankenstein monster. so have a Happy Halloween.

Stefan
  ----- Original Message ----- 
  From: John DePasquale 
  To: activeperl@listserv.ActiveState.com 
  Sent: Wednesday, October 28, 2015 10:13 AM
  Subject: it's probably just me


  Hi perl mavens,

  I'm sure I just don't understand something here, but this one makes zero 
sense to me:

  The following snippet prints a 1

                  local @aList;

                  push @aList, ['first','second','third'];

                  my $nCount = @aList;

                  print "count: $nCount";

   

  BUT, if I add one seemingly irrelevant line ( the second one below ), 
something crazy happens:

                  local @aList;

                  print "non-existent value: $aList[0][0]\n";

                  push @aList, ['first','second','third'];

                  my $nCount = @aList;

                  print "count: $nCount";

   

  instead of printing a 1, the last line prints a 2

  So the reference in the first print statement to $aList[0][0] appears to have 
the affect of creating a row in the array.

  Is this supposed to work this way? Why would such a reference to a 
non-existent array row result in the creation of an array row?

  Thank you.

  -          john

   

  John DePasquale

  Chief Executive Officer

  Paradigm Consulting

  "Proudly presenting the Vinopedia System"

  www.vinopedia.us

  49 Dalby Street

  Newton, MA  02458

  Mobile: 617-610-2424

  Fax: 617-600-7326


------------------------------------------------------------------------------



------------------------------------------------------------------------------


  _______________________________________________
  ActivePerl mailing list
  ActivePerl@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to