Re: commify_series script in cookbook page 94
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Mon, 31 Mar 2008 13:57:34 -0700
Rob Dixon wrote:
Dr.Ruud wrote:Rob Dixon schreef:It's equivalent to:TIMTOWTDI.
my $sepchar = ',';
foreach (@_) {
if (/,/) {
$sepchar = ';';
last;
}
}
And IMO is much better written that way.
But I'm sure you'll agree that some ways are more awkward or obfuscated
than others.
Another shortcutting alternative:
my $sepchar = ',';
for (@_) { $sepchar = ";" and last if /\Q$sepchar/ }
This relies on ';' being true, and uses 'and' in void context.
"'and' in void context"? 'and' has two operands so how is it in void context?
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- 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
- Re: commify_series script in cookbook page 94
- From: Rob Dixon
- Re: commify_series script in cookbook page 94
- From: Dr.Ruud
- Re: commify_series script in cookbook page 94
- From: Rob Dixon
- Interpolate variable in a __DATA__ block
- Prev by Date: Re: commify_series script in cookbook page 94
- Previous by thread: Re: commify_series script in cookbook page 94
- Next by thread: Re: Interpolate variable in a __DATA__ block
- Index(es):