Re: commify_series script in cookbook page 94
- From: rob.dixon@xxxxxxx (Rob Dixon)
- Date: Mon, 31 Mar 2008 11:10:48 +0100
Richard Lee wrote:
Dr.Ruud wrote:
Richard Lee schreef:I understood the original but I am not so sure of your solution??
While reading perl cookbook, I came to page 94 and having a hard timeShortcutting alternative:
understanding this particular phrase
my $sepchar = grep( /,/ => @_ ) ? ";" : ",";
my $sepchar = ",";
for (@_) { /,/ and $sepchar = ";" and last }
but (unless @_ is quite big) the grep alternative is likely to be
faster.
Can you write it out completely so that I can try it out?
It's equivalent to:
my $sepchar = ',';
foreach (@_) {
if (/,/) {
$sepchar = ';';
last;
}
}
And IMO is much better written that way.
HTH,
Rob
.
- Follow-Ups:
- Re: commify_series script in cookbook page 94
- From: Dr.Ruud
- Re: commify_series script in cookbook page 94
- References:
- Interpolate variable in a __DATA__ block
- From: Trudge
- Re: Interpolate variable in a __DATA__ block
- From: Gunnar Hjalmarsson
- Re: Interpolate variable in a __DATA__ block
- From: Trudge
- Re: Interpolate variable in a __DATA__ block
- From: Chas. Owens
- commify_series script in cookbook page 94
- From: Richard Lee
- Re: commify_series script in cookbook page 94
- From: Dr.Ruud
- Re: commify_series script in cookbook page 94
- From: Richard Lee
- Interpolate variable in a __DATA__ block
- Prev by Date: Re: Load hash from a scalar
- Next by Date: Problem with STAT under Windows
- Previous by thread: Re: commify_series script in cookbook page 94
- Next by thread: Re: commify_series script in cookbook page 94
- Index(es):
Relevant Pages
|