Re: small puzzle

2014-04-27 Thread Harry Putnam
Shawn H Corey writes: > On Fri, 25 Apr 2014 12:39:21 -0700 > John SJ Anderson wrote: > >> Perl doesn't charge you by the lines of code you use, so doing this: >> >>my $re = shift; >>$re = qr/$re/; >> >> is just fine. > > This also works: > > my $re = qr/$ARGV[0]/; > shift @ARGV

Re: small puzzle

2014-04-27 Thread Harry Putnam
Uri Guttman writes: > On 04/25/2014 12:55 PM, Harry Putnam wrote: >> Uri Guttman writes: >> >>> why would you expect anything but 1 as the value? shift will return 1 >>> value or undef. that anon array will be dereferenced to an array with >>> 1 entry. the array is in scalar context which return

Re: small puzzle

2014-04-25 Thread John SJ Anderson
*puts on List Mom hat* Okay, we're done here. The original question was asked and answered (a couple times). Let's move on and get back to dealing with Perl questions, not personalities. thanks, john. *takes List Mom hat back off* -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For a

Re: small puzzle

2014-04-25 Thread Rob Dixon
On 26/04/2014 02:16, Uri Guttman wrote: On 04/25/2014 12:55 PM, Harry Putnam wrote: Uri Guttman writes: why would you expect anything but 1 as the value? shift will return 1 value or undef. that anon array will be dereferenced to an array with 1 entry. the array is in scalar context which ret

Re: small puzzle

2014-04-25 Thread Uri Guttman
On 04/25/2014 12:55 PM, Harry Putnam wrote: Uri Guttman writes: why would you expect anything but 1 as the value? shift will return 1 value or undef. that anon array will be dereferenced to an array with 1 entry. the array is in scalar context which returns its size. elementary!

Re: small puzzle

2014-04-25 Thread Shawn H Corey
On Fri, 25 Apr 2014 12:39:21 -0700 John SJ Anderson wrote: > Perl doesn't charge you by the lines of code you use, so doing this: > >my $re = shift; >$re = qr/$re/; > > is just fine. This also works: my $re = qr/$ARGV[0]/; shift @ARGV; -- Don't stop where the ink does.

Re: small puzzle

2014-04-25 Thread John SJ Anderson
On Fri, Apr 25, 2014 at 12:18 PM, Harry Putnam wrote: > About just using 'shift': How I happened to be using that weird > looking notation at all was because I thought it was a way to avoid > the extra step of compiling the rgx in qr// after shifting. My advice to you on this point would be tha

Re: small puzzle

2014-04-25 Thread Harry Putnam
John SJ Anderson writes: > In general, anywhere you're doing '@{[shift]}', unless you REALLY know > what's going on and why you'd want to do that ... instead just do > 'shift'. Thanks for the in depth answer. Very helpful. You've helped fill some tragic holes in my basic knowledge of perl. I'

Re: small puzzle

2014-04-25 Thread Harry Putnam
Uri Guttman writes: > why would you expect anything but 1 as the value? shift will return 1 > value or undef. that anon array will be dereferenced to an array with > 1 entry. the array is in scalar context which returns its > size. elementary! ^ my dear Watson. Thank you Mr U

Re: small puzzle

2014-04-24 Thread Uri Guttman
On 04/24/2014 11:40 PM, Harry Putnam wrote: Some simple code that is similar to other code I've written and used is returning something I don't understand. I've used the notation below for shifting off elements of AR many times but don't recall seeing this output. I think I know what is happeni

Re: small puzzle

2014-04-24 Thread John SJ Anderson
On Thu, Apr 24, 2014 at 8:40 PM, Harry Putnam wrote: > my $dir2sr = @{[shift]}; This shifts an element off @ARGV, makes an array reference containing a single element (the value that was just shifted off), then deferences that arrayref to create an array (which still contains a single element, t

small puzzle

2014-04-24 Thread Harry Putnam
Some simple code that is similar to other code I've written and used is returning something I don't understand. I've used the notation below for shifting off elements of AR many times but don't recall seeing this output. I think I know what is happening but I don't understand why. Is the second