The stupid question is the question not asked | |
PerlMonks |
Re: Changing arrays w/ and w/o regexby Corion (Patriarch) |
on Nov 09, 2021 at 12:25 UTC ( [id://11138608]=note: print w/replies, xml ) | Need Help?? |
lc is a function and in your first case, you are throwing away the result of the function. This is also why Perl warns you about throwing away the result of a function . "void context" means that you don't care about the result of a function, which is uncommon when calling a function. In the second case, you are using the result of the function, by using it in the replacement part of s///. When rewriting an array, it's common to use the map function to turn each element of the (old) array into a new value:
I believe this can be written even shorter as
... but that is overly short especially if you are not yet familiar with map. Updated: Added map as example
In Section
Seekers of Perl Wisdom
|
|