![]() |
|
Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^4: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staffby likbez (Sexton) |
on Sep 15, 2020 at 12:10 UTC ( #11121788=note: print w/replies, xml ) | Need Help?? |
Yes I did not know about wantarray. Sorry about that. That can be used to distinguish between function and sub calls. Thank you.
wantarray FYI instead of $line =~ s/\s+$//; # rtrim() in Perl you can use AWK hack in split function: It is marginally faster. Use of regex for trimming white space reminds me an anecdote about general who sent a tank division to capture an unarmed village with natives. IMHO, this is too heavy instrument unless regex engine is really sophisticated and optimize such case into tr/ //d style implementation. Just look at the overhead on a million lines file:
so we are talking about real money here (without regex time is 0.14). May be extending tr to stop after the first symbol which is not in set1 would also be beneficial and faster. In my use of Perl I would prefer an option in the open statement that would do the job for all lines read, as this is the most common use case. Something like open(file,'<t(rln)','test')
In Section
Meditations
|
|