> On Jul 31, 2015, at 4:39 AM, David Emanuel da Costa Santiago > <deman...@gmail.com> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > > > Hello. > > > Thanks for your reply. > > > I remember that i did some performance tests and > > $string = $string ."something" > > had better performance than > > $string .= “something"
Those two lines should result in exactly the same machine instructions. They are two different ways of writing the same thing. There should be no difference in perfomance. > which matched the results of (link to stack overflow) > http://stackoverflow.com/questions/3104493/performance-with-perl-strings That post compares the following 3 ways of forming a long string (see the benchmark program posted by sebthebert): 1. $string = ‘A’ $string .= ‘B’; $string. = ‘C’; 2. $string = ‘A’ . ‘B’ . ‘C’; 3. $string = join(‘’, (‘A’, ‘B’, ‘C’) ); It does not compare $string .= ‘X’ with $string = $string . ‘X’ Write and run your own benchmark comparing those two cases and post your results here. (#2 turns out to be fastest, with #3 a close second) In any case, you probably shouldn’t be worrying about such minor differences in execution speed. Reliability, accuracy, and ease of maintenance are much more important qualities for software to have. Operators such as ‘.=‘ permit shorter source code and fewer chances for errors. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/