harangzsolt33 has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; $| = 1; my (undef, $min, $hr, undef, $mon) = localtime; # Okay # my (undef, $min, $hr, , $mon) = localtime; # Okay but unexpecte +d/weird result # my ( , $min, $hr, , $mon) = localtime; # Syntax error print "\nMinutes = $min\nHours = $hr\nMonths = $mon\n\n";
I have noticed that it's also okay to just write blank, but when I try to substitute blank in place of the first undef, I get a syntax error. What would be the official or best practice to skip a variable in a list? I am asking this question, because what if they change Perl and in version 5.79 they introduce some new feature which means that "undef" as a placeholder will raise an error or warning in the code?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: skipping unwanted list items
by ikegami (Patriarch) on May 10, 2026 at 11:49 UTC | |
by harangzsolt33 (Curate) on May 10, 2026 at 12:47 UTC | |
|
Re: skipping unwanted list items
by LanX (Saint) on May 10, 2026 at 07:39 UTC | |
by LanX (Saint) on May 10, 2026 at 12:29 UTC | |
by harangzsolt33 (Curate) on May 10, 2026 at 12:44 UTC |