develooper Front page | perl.beginners | Postings from September 2022

Iterating over Arrays

Thread Next
From:
William Torrez Corea
Date:
September 25, 2022 01:00
Subject:
Iterating over Arrays
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
⠈⠳⣄⠀⠀⠀⠀

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About