From: Thierry Vignaud <tvignaud@mandrakesoft.com>

- "\<" and "\>" can be safely replaced with "<" and ">"

- "$var =~ /^string$/" is better written "$var eq 'string'"

- $i is better written without the double quotes

- it's not safe to use for without "my"ing the iteration variable

- "print foreach @array" is better written "print @array"

- declare variables

- ".*" is useless at the end of a regexp

- "$a[@a] = $foo" is a rather obfuscated syntax for "push @a, $foo"... 
  let's not opencoding language basic operators...

- ignoring return value from a regexp is very bad: this can results in
  working on previous value of $1, $2, ...

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/scripts/checkstack.pl |   29 ++++++++++++++---------------
 1 files changed, 14 insertions(+), 15 deletions(-)

diff -puN scripts/checkstack.pl~checkstack-fixes scripts/checkstack.pl
--- 25/scripts/checkstack.pl~checkstack-fixes	2004-06-08 01:29:11.874609448 -0700
+++ 25-akpm/scripts/checkstack.pl	2004-06-08 01:29:11.882608232 -0700
@@ -23,6 +23,7 @@
 # $1 (first bracket) matches the size of the stack growth
 #
 # use anything else and feel the pain ;)
+my (@stack, $re, $x, $xs);
 {
 	my $arch = shift;
 	if ($arch eq "") {
@@ -31,25 +32,25 @@
 
 	$x	= "[0-9a-f]";	# hex character
 	$xs	= "[0-9a-f ]";	# hex character or space
-	if ($arch =~ /^arm$/) {
+	if ($arch eq 'arm') {
 		#c0008ffc:	e24dd064	sub	sp, sp, #100	; 0x64
 		$re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
 	} elsif ($arch =~ /^i[3456]86$/) {
 		#c0105234:       81 ec ac 05 00 00       sub    $0x5ac,%esp
 		$re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%esp$/o;
-	} elsif ($arch =~ /^ia64$/) {
+	} elsif ($arch eq 'ia64') {
 		#e0000000044011fc:       01 0f fc 8c     adds r12=-384,r12
 		$re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
-	} elsif ($arch =~ /^mips64$/) {
+	} elsif ($arch eq 'mips64') {
 		#8800402c:       67bdfff0        daddiu  sp,sp,-16
 		$re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
-	} elsif ($arch =~ /^mips$/) {
+	} elsif ($arch eq 'mips') {
 		#88003254:       27bdffe0        addiu   sp,sp,-32
 		$re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
-	} elsif ($arch =~ /^ppc$/) {
+	} elsif ($arch eq 'ppc') {
 		#c00029f4:       94 21 ff 30     stwu    r1,-208(r1)
 		$re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
-	} elsif ($arch =~ /^ppc64$/) {
+	} elsif ($arch eq 'ppc64') {
 		#XXX
 		$re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
 	} elsif ($arch =~ /^s390x?$/) {
@@ -62,6 +63,7 @@
 }
 
 sub bysize($) {
+	my ($asize, $bsize);
 	($asize = $a) =~ s/.*	+(.*)$/$1/;
 	($bsize = $b) =~ s/.*	+(.*)$/$1/;
 	$bsize <=> $asize
@@ -70,8 +72,9 @@ sub bysize($) {
 #
 # main()
 #
-$funcre = qr/^$x* \<(.*)\>:$/;
-while ($line = <STDIN>) {
+my $funcre = qr/^$x* <(.*)>:$/;
+my $func;
+while (my $line = <STDIN>) {
 	if ($line =~ m/$funcre/) {
 		$func = $1;
 	}
@@ -85,7 +88,7 @@ while ($line = <STDIN>) {
 			$size += 0x80000000;
 		}
 
-		$line =~ m/^($xs*).*/;
+		next if $line !~ m/^($xs*)/;
 		my $addr = $1;
 		$addr =~ s/ /0/g;
 		$addr = "0x$addr";
@@ -97,12 +100,8 @@ while ($line = <STDIN>) {
 			$padlen -= 8;
 		}
 		next if ($size < 100);
-		$stack[@stack] = "$intro$size\n";
+		push @stack, "$intro$size\n";
 	}
 }
 
-@sortedstack = sort bysize @stack;
-
-foreach $i (@sortedstack) {
-	print("$i");
-}
+print sort bysize @stack;
_