Re: Brackets in scalar and array

2014-05-29 Thread Shawn H Corey
On Thu, 29 May 2014 16:02:44 -0700 Jim Gibson wrote: > > On May 29, 2014, at 3:34 PM, Sherman Willden wrote: > > > Maybe I'm missing the point but isn't the following code the > > problem's answer? Please let me know if I am off base. > > Just a bit off (see below). > > > #!/usr/bin/perl > >

Re: Brackets in scalar and array

2014-05-29 Thread Jim Gibson
On May 29, 2014, at 3:34 PM, Sherman Willden wrote: > Maybe I'm missing the point but isn't the following code the problem's > answer? Please let me know if I am off base. Just a bit off (see below). > #!/usr/bin/perl > > my @test = "a b c"; That is a scalar on the right-hand side. You end u

Re: Brackets in scalar and array

2014-05-29 Thread Sherman Willden
Maybe I'm missing the point but isn't the following code the problem's answer? Please let me know if I am off base. Thank you; Sherman #!/usr/bin/perl my @test = "a b c"; ($test)=(@test); print "\$test: $test\n"; @test = "a b c"; $test = @test; print "\$test: $test\n"; # output lines after

Re: Brackets in scalar and array

2014-05-29 Thread Shawn H Corey
On Thu, 29 May 2014 16:27:36 -0500 Steve Kaftanski wrote: > Hope this helps! -Steve Kaftanski, MadMongers.org (Madison.pm > Wisconsin). Here are some links you might find useful: * official site * beginners' help

Re: Brackets in scalar and array

2014-05-29 Thread Steve Kaftanski
I am also a long-time lurker / First time responder, so hopefully I'll answer acceptably per the email-list conventions... I will assume that some of the basic references are available to you (or that others will cite them correctly... as they appear to be doing; many responses so far.) Anyway,

Re: Brackets in scalar and array

2014-05-29 Thread Andy Bach
On Thu, May 29, 2014 at 3:20 PM, James Kerwin wrote: > Explain the difference between: > > ($test)=(@test); > > And > > $test=@test; > Parens on the left make it a "list" context, parens on the right make it a list. Bare scalar on the left make it "scalar context, bare array assigned in a scalar

Re: Brackets in scalar and array

2014-05-29 Thread James Kerwin
It seems so obvious now. Should possibly have just tested it myself before asking... Thank you all for the explanations! On 29 May 2014 21:36, "Jim Gibson" wrote: > > On May 29, 2014, at 1:20 PM, James Kerwin wrote: > > > Hello all, long time lurker, first time requester... > > > > I have a Perl

Re: Brackets in scalar and array

2014-05-29 Thread Shawn H Corey
On Thu, 29 May 2014 13:36:11 -0700 Jim Gibson wrote: > Try it yourself: > > % perl -e '@t=qw(1 2 3);$t=@t;print qq($t\n);' > 3 > % perl -e '@t=qw(1 2 3);($t)=@t;print qq($t\n);' > 1 > % perl -e '@t=qw(1 2 3);($t)=(@t);print qq($t\n);' > 1 This would be clearer if you used letters: $ perl -E'@t

Re: Brackets in scalar and array

2014-05-29 Thread Jim Gibson
On May 29, 2014, at 1:20 PM, James Kerwin wrote: > Hello all, long time lurker, first time requester... > > I have a Perl exam tomorrow and came across a question that I just cannot > find an answer to (past paper, this isn't cheating or homework etc.). > > Explain the difference between: > >

Re: Brackets in scalar and array

2014-05-29 Thread Hao Wu
Hi, you can find the answer here, http://perlmaven.com/scalar-and-list-context-in-perl Good Luck to your exam! On Thu, May 29, 2014 at 1:20 PM, James Kerwin wrote: > Hello all, long time lurker, first time requester... > > I have a Perl exam tomorrow and came across a question that I just can