A journey through whitespace cleanup - Perl5 and split

Running through some older Perl5 code, I found someone using grep with a split to cleanup white space on some incoming data.

Found, this seemed confusing to me with lots of extra complexity:
my @line = grep { s/\s*$// } split /\|/, $_;


First Pass:
my @line = split /\|\s*/, $_;


But my guess is that all wrapping white space should be removed:
my @line = split /\s*\|\s*/, $_;


Even better (and more readable), use the Perl magic context:
my @line = split /\s*\|\s*/;


I would love to make that a cleaner regex but that will have to be another day...

Comments

  1. Some slot machines have lots of exciting bells and whistles that are be} enjoyable to play. So assume again to the objectives you set before making your alternative before you resolve. She didn't want tutorial analysis to gauge this latter pattern. 88 Fortunes® is the perfect slot expertise for gamers to check their luck. Featuring 파라오카지노 도메인 10 Free Games that can be be} endlessly re-triggered, 88 Fortunes features the “All Up” recreation fashion, which provides gamers the possibility to purchase gold symbols to increase their winning opportunities. In recent years, slot machine designers have labored intently with video game architects have the ability to} bring a number of the} visual appeal found in digital gaming to the playing area.

    ReplyDelete

Post a Comment

Popular posts from this blog

BootstrapX clickover

2 ways to get SQLite to put dates into columns

Template Toolkit Debugging inside of Perl Dancer