Iterating over Arrays

William Torrez Corea <[email protected]>
Newsgroups gmane.comp.lang.perl.beginners
Message-ID <CAGiORHd07yn6e=Vo_S4aziDDeT0kCBMuo9=L4Q5kyeBsKexLKw@mail.gmail.com>
What happen with my code?

use strict;
use warnings;
use diagnostics;

my @words = ("this","that");

# With this code
$words[5] = "bad idea";

for my $element (@words){
        print "$element\n";
}

~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"words.pl" 13L, 167B                           1,1           All


Use of uninitialized value $element in concatenation (.) or string at
words.pl line 11.
 at words.pl line 11.

-- 

With kindest regards, William.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.