in reply to Re: Pearls (not really) of Perl programming
in thread Pearls (not really) of Perl programming
What's bad about this? Sure, there are other ways to do it, but it doesn't seem particularly egregious to me. For those following along at home, here are some other ways:
$default_title =~ s/(.{50}).*/$1/; $default_title =~ s/./$ctr++<50?$&:""/ge; $default_title = pack "A50", $default_title; $default_title = join "", (split //, $default_title)[0..50];
Personally, I like the original much better than these alternatives. The only other way that I would possibly use is:
substr($default_title, 50) = "";
But substr as an lvalue is not something everyone knows about, so it's not clearly the best option.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Pearls (not really) of Perl programming
by ihb (Deacon) on Nov 26, 2004 at 02:14 UTC |
In Section
Meditations