TieUpYourCamel has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to combine that onto one line? I've tried several variations, all of them generate an error, shown in the comments below the code:my @odds = (1,3,5,7,9); print pop(@odds);
What's particularly curious is I know I've used the @{} construct before to explicitly define an array, using XML::Simple.use strict; use warnings; use v5.30; #works my @odds = (1,3,5,7,9); print pop(@odds); #9 (no error) print pop((2,4,6)); # Experimental pop on scalar is now forbidden ... near "))" print pop(@(2,4,6)); # Number found where operator expected ... near "@(2" # (Missing operator before 2?) # syntax error ... near "@(2" print pop(@{2,4,6}); # Useless use of a constant (2) in void context ... line 19. # Useless use of a constant (4) in void context ... line 19. # Can't use string ("6") as an ARRAY ref while "strict refs" in use .. +. line 19.
I must be missing something, particularly in that first example: print pop((2,4,6)); generates the error "Experimental pop on scalar is now forbidden". However, (2,4,6) clearly isn't a scalar.$ErrorResponse = $xml->XMLin($objResponse->content, ForceArray => 1); @Errors = @{$ErrorResponse->{Errors}};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing an array without a name to pop()
by Paladin (Vicar) on Dec 03, 2019 at 19:16 UTC | |
|
Re: passing an array without a name to pop()
by haukex (Archbishop) on Dec 03, 2019 at 20:59 UTC | |
|
Re: passing an array without a name to pop()
by ikegami (Patriarch) on Dec 03, 2019 at 21:36 UTC | |
|
Re: passing an array without a name to pop()
by ikegami (Patriarch) on Dec 03, 2019 at 21:44 UTC | |
|
Re: passing an array without a name to pop()
by BillKSmith (Monsignor) on Dec 03, 2019 at 21:27 UTC | |
|
Re: passing an array without a name to pop()
by johngg (Canon) on Dec 03, 2019 at 22:44 UTC | |
|
Re: passing an array without a name to pop()
by The_Dj (Scribe) on Dec 04, 2019 at 06:45 UTC | |
|
Re: passing an array without a name to pop()
by Fletch (Bishop) on Dec 03, 2019 at 19:15 UTC | |
by haukex (Archbishop) on Dec 03, 2019 at 20:51 UTC | |
by Fletch (Bishop) on Dec 03, 2019 at 21:26 UTC |