Perl: the Markov chain saw | |
PerlMonks |
Re: How Perl can push array into array and then how retrieveby kcott (Archbishop) |
on Nov 25, 2021 at 04:30 UTC ( [id://11139098]=note: print w/replies, xml ) | Need Help?? |
I'm guessing somewhat regarding what you want to achieve. Always put strict and warnings at the top of your code. In this instance, that would have alerted you to the fact that there was something wrong with $f. I was unsure why you wanted to increment $i inside the loop. In my version, I changed $i+=2 to $i+2. Here's a couple of ways of doing what I think you want:
Output:
See also: "perlintro: Arrays"; "perldsc - Perl Data Structures Cookbook"; "perllol - Manipulating Arrays of Arrays in Perl". — Ken
In Section
Seekers of Perl Wisdom
|
|