Re: commify_series script in cookbook page 94

2008-03-31 Thread Rob Dixon
John W. Krahn wrote: > Rob Dixon wrote: >> Dr.Ruud wrote: >>> Rob Dixon schreef: It's equivalent to: my $sepchar = ','; foreach (@_) { if (/,/) { $sepchar = ';'; last; } } And IMO is much better written that way. >>> T

Re: commify_series script in cookbook page 94

2008-03-31 Thread Rob Dixon
Chas. Owens wrote: > On Mon, Mar 31, 2008 at 2:30 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > snip >> > my $sepchar = ','; >> > for (@_) { $sepchar = ";" and last if /\Q$sepchar/ } >> >> This relies on ';' being true, and uses 'and' in void context. >> > snip > > There is nothing wrong w

Re: commify_series script in cookbook page 94

2008-03-31 Thread John W. Krahn
Rob Dixon wrote: Dr.Ruud wrote: Rob Dixon schreef: It's equivalent to: my $sepchar = ','; foreach (@_) { if (/,/) { $sepchar = ';'; last; } } And IMO is much better written that way. TIMTOWTDI. But I'm sure you'll agree that some ways are more awkward or obfuscate

Re: commify_series script in cookbook page 94

2008-03-31 Thread Chas. Owens
On Mon, Mar 31, 2008 at 2:30 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: snip > > my $sepchar = ','; > > for (@_) { $sepchar = ";" and last if /\Q$sepchar/ } > > This relies on ';' being true, and uses 'and' in void context. > snip There is nothing wrong with using and in void context. If

Re: commify_series script in cookbook page 94

2008-03-31 Thread Rob Dixon
Dr.Ruud wrote: > Rob Dixon schreef: >> Richard Lee wrote: >>> Dr.Ruud wrote: Richard Lee schreef: > > While reading perl cookbook, I came to page 94 and having a hard > time understanding this particular phrase > my $sepchar = grep( /,/ => @_ ) ? ";" : ","; Shortcutting a

Re: commify_series script in cookbook page 94

2008-03-31 Thread Dr.Ruud
Rob Dixon schreef: > Richard Lee wrote: >> Dr.Ruud wrote: >>> Richard Lee schreef: While reading perl cookbook, I came to page 94 and having a hard time understanding this particular phrase my $sepchar = grep( /,/ => @_ ) ? ";" : ","; >>> >>> Shortcutting alternative: >>> m

Re: commify_series script in cookbook page 94

2008-03-31 Thread Rob Dixon
Richard Lee wrote: > Dr.Ruud wrote: >> Richard Lee schreef: >> >> >>> While reading perl cookbook, I came to page 94 and having a hard time >>> understanding this particular phrase >>> >>> my $sepchar = grep( /,/ => @_ ) ? ";" : ","; >>> >> Shortcutting alternative: >> >> my $sepchar =

Re: commify_series script in cookbook page 94

2008-03-30 Thread Richard Lee
Dr.Ruud wrote: Richard Lee schreef: While reading perl cookbook, I came to page 94 and having a hard time understanding this particular phrase my $sepchar = grep( /,/ => @_ ) ? ";" : ","; Shortcutting alternative: my $sepchar = ","; for (@_) { /,/ and $sepchar = ";" and last

Re: commify_series script in cookbook page 94

2008-03-30 Thread Dr.Ruud
Richard Lee schreef: > While reading perl cookbook, I came to page 94 and having a hard time > understanding this particular phrase > > my $sepchar = grep( /,/ => @_ ) ? ";" : ","; Shortcutting alternative: my $sepchar = ","; for (@_) { /,/ and $sepchar = ";" and last } but (unless @_ i

Re: commify_series script in cookbook page 94

2008-03-30 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: While reading perl cookbook, I came to page 94 and having a hard time understanding this particular phrase my $sepchar = grep( /,/ => @_ ) ? ";" : ","; I recognize the ternary operator and grep but I am not sure how they are forming the meaning together

Re: commify_series script in cookbook page 94

2008-03-30 Thread John W. Krahn
yitzle wrote: my $sepchar = grep( /,/ => @_ ) ? ";" : ","; And I also don't understand what ";" is doing in the ternary operator?? The ";" is what is returned if the condition is TRUE. "( / ,/ => @_)" is a(n anonymous) hash. No it is not. /,/ and @_ are just two arguments to the grep() fu

Re: commify_series script in cookbook page 94

2008-03-30 Thread Rob Dixon
Richard Lee wrote: > > While reading perl cookbook, I came to page 94 and having a hard time > understanding this particular phrase > > my $sepchar = grep( /,/ => @_ ) ? ";" : ","; > > I recognize the ternary operator and grep but I am not sure how they are > forming the meaning together. > >

Re: commify_series script in cookbook page 94

2008-03-30 Thread yitzle
> my $sepchar = grep( /,/ => @_ ) ? ";" : ","; > And I also don't understand what ";" is doing in the ternary operator?? The ";" is what is returned if the condition is TRUE. "( / ,/ => @_)" is a(n anonymous) hash. I've had no idea that grep can operate on a hash. However, it seems that "grep( /

Re: commify_series script in cookbook page 94

2008-03-30 Thread John W. Krahn
Richard Lee wrote: While reading perl cookbook, I came to page 94 and having a hard time understanding this particular phrase my $sepchar = grep( /,/ => @_ ) ? ";" : ","; I recognize the ternary operator and grep but I am not sure how they are forming the meaning together. I thought grep