On Monday 05 Oct 2009 22:49:47 Slick wrote: > Just clarification. At this time I have not written any of my code (dont' > know where to begin yet, however the website that I am looking at > perl.begin.org seems to have diffrent methods for one item. I have seen > @ for arrays written like this: @myarray ,but I have also seen an array > per the perl.begin.org writting like: $primes[$num_primes]. Are they > both the same? Because it would be easier in my opinion to write: > > @myarray = 4; > instead of writing this: > $primes[$num_primes] = 2; >
You probably mean : http://perl-begin.org/tutorials/perl-for-newbies/part1/#page--arrays--DIR $primes[$num_primes] assigns to index No. $num_primes (where the array starts at index 0) of @primes. Doing {{{ @myarray = 4 }}} won't do what you want (as opposed to PHP's {{{ $myarray[] = 4 }}}, but {{{ push @myarray, 4; }}} will probably do what you want. The "=" assignment overrides the entire variable. Regards, Shlomi Fish > Am I mising something, or are these two things interchangable? > Jason H. Owens > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Funny Anti-Terrorism Story - http://shlom.in/enemy Chuck Norris read the entire English Wikipedia in 24 hours. Twice. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/