Variable declaration - C vs script style
- From: markoa <marko.anastasov@xxxxxxxxx>
- Date: Tue, 31 Jul 2007 05:01:10 -0700
Hello,
I've been wondering whether there are any differences in performance
when declaring variables within loops
comparing to all forward declarations. I'm mostly writing up to a few
hundred lines long scripts, but I need
relatively a lot variables, which look kind of ugly and IMO make the
script less readable when declared all
at the top. For example,
my ($var1, var2, var3, var4, var5, ...);
my (another set of variables);
while (...) {
$var1 = ...
$var2 = &foo($var1);
...
if ($var3) {
...
}
for ($var4 : ...)
}
vs
while (...) {
my $var1 = ...
my $var2 = &foo($var1);
...
my $var3 = ....;
if ($var3) {
...
}
for (my $var4 : ...)
}
Will the latter approach lead to more memory allocation and/or
significantly more work
for the garbage collector?
Marko
.
- Follow-Ups:
- Re: Variable declaration - C vs script style
- From: J. Gleixner
- Re: Variable declaration - C vs script style
- From: bugbear
- Re: Variable declaration - C vs script style
- Prev by Date: Re: Perl threads
- Next by Date: Re: threads and logfile rotation
- Previous by thread: define an array in perl
- Next by thread: Re: Variable declaration - C vs script style
- Index(es):
Relevant Pages
|