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}};
In reply to passing an array without a name to pop() by TieUpYourCamel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |