Hello Steven
Am Dienstag, 8. M�rz 2005 15.19 schrieb Steven Schubiger:
> > # trim right space away. I'm shure there is a shorter
> > # and more elegant solution
> > #
> > @parts= map { do {$_=~s/\s*$//; $_ } } @parts;
>
> Regular expressions have a tendency to be slower, than functions
> that achieve aquivalent results; but, chop() cannot be considered being
> used in above statement, since chops returns the trimmed character.
Must chop be used in the above statement? @parts contains no line end - I
think - after something like
my @parts= $line=~/^(.{7}).{6}(.{6}).{5}/o;
?
> s/// operates by default on $_, as many other built-in functions do,
> thus:
>
> @parts = map { do { s/\s*$//; $_ } @parts;
Thanks :-)
[just a very little typo note: one right '}' is missing]
What do you think if one would also put an o modifier here?
@parts = map { do { s/\s*$//o; $_ } } @parts;
Would this still be (much) slower than the tr/// version?
[hmm... ok... I could test it myself]
> Also, consider using the tr operator instead of s/// for speed-up
> purposes.
Oups - I missed this possibility... which would be (just to be complete :-)
@parts = map { do { tr/ //d; $_ }} @parts; # d modifier required
Thanks again :-)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>