in reply to Whats quicker - passing along as variable to sub, or global var?
I'm trying to work out what would be quicker
Then Benchmark it.
Be aware, these are gonna be pretty large strings... i.e thousands, if not tens of thousands worth of lines (as they are "wiki" articles)
Then you should avoid making copies. Note that passing strings to functions does not make a copy (@_ aliases), but my $long_content = $_[0]; does.
A good way to avoid copying and still get the scoping benefits of argument passing is by using references explicitly. I guess you're familiar with perlreftut and perlref...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Whats quicker - passing along as variable to sub, or global var?
by ultranerds (Hermit) on Apr 08, 2011 at 13:12 UTC | |
by moritz (Cardinal) on Apr 08, 2011 at 13:45 UTC | |
by ultranerds (Hermit) on Apr 08, 2011 at 13:50 UTC | |
by bart (Canon) on Apr 08, 2011 at 21:33 UTC | |
by jethro (Monsignor) on Apr 08, 2011 at 14:04 UTC |