#! perl use strict; use warnings; my @x = qw(Initial list of words 1); my $y = 'Initial string 1'; show('With parentheses'); my @z = ( time() ? @x = qw(Words_z from conditional) : $y ) = foo(); print "\@z = (@z)\n"; show('After assignment to LHS'); @x = qw(Initial list of words 2); $y = 'Initial string 2'; show('Without parentheses'); my @w = time() ? @x = qw(Words_w from conditional) : $y = foo(); print "\@w = (@w)\n"; show('After assignment to LHS'); sub foo { if (wantarray()) { print "\nfoo called in list context\n"; return qw(sub_foo word list); } else { print "\nfoo called in scalar context\n"; return 'String_from_foo'; } } sub show { my ($heading) = @_; print "\n$heading:\n\n"; print "\@x = (@x)\n"; print "\$y = '$y'\n"; } #### 17:35 >perl 678_SoPW.pl With parentheses: @x = (Initial list of words 1) $y = 'Initial string 1' foo called in scalar context @z = (String_from_foo) After assignment to LHS: @x = (Words_z from conditional) $y = 'Initial string 1' Without parentheses: @x = (Initial list of words 2) $y = 'Initial string 2' foo called in scalar context @w = (String_from_foo) After assignment to LHS: @x = (Words_w from conditional) $y = 'Initial string 2' 17:35 >perl -v This is perl 5, version 18, subversion 0 (v5.18.0) built for MSWin32-x86-multi-thread-64int