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
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
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
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
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
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
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 =
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
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
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
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
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.
>
>
> 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( /
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
14 matches
Mail list logo