# Change this: $string = "hello world"; @array = qw(ABC DEF); %hash = (A=>1, B=>2); # To this: my $string = "hello world"; my @array = qw(ABC DEF); my %hash = (A=>1, B=>2); # Change this: # '$name' is global here @names = qw(Bob Fred); foreach $name (@names) { print "Name: $name\n"; } # To this: my @names = qw(Bob Fred); foreach my $name (@names) { # Now '$name' only exists in this block print "Name: $name\n"; } # Change this: # Likewise, '$digit' is global here @digits = (5,3,4); foreach $digit (@digits) { $number = 10*$number + $digit; } print "Number: $number\n"; # To this (variables used in an outer scope ('$number') # will have to be declared in an outer scope): my @digits = (5,3,4); my $number = 0; foreach my $digit (@digits) # Now '$digit' only exists in this block $number = 10*$number + $digit; } print "Number: $number\n"; # Change this: sub my_sub { ($arg1, $arg2) = @_; print "Arg1: $arg1 Arg2: $arg2\n"; } # To this: sub my_sub { my ($arg1, $arg2) = @_; print "Arg1: $arg1 Arg2: $arg2\n"; } # Using DBI? You can change this: $sth->bind_columns(\$field1, \$field2); while ($sth->fetch) { print "F1: $field1 F2: $field2\n"; } # To this (the '\' is distributed over a list of values): $sth->bind_columns(\my ($field1, $field2)); while ($sth->fetch) { print "F1: $field1 F2: $field2\n"; }