$ perl -Mstrict -Mwarnings -E 'my $foo; say ++$foo'
1
$ perl -Mstrict -Mwarnings -E 'my $foo; say $foo + 1'
Use of uninitialized value $foo in addition (+) at -e line 1.
1
####
foreach my $employee (@employees) {
if ( $employee->salary < $threshold ) {
increase_salary( $employee, 3_000 );
}
}
##
##
if ( defined $threshold ) {
foreach my $employee (@employees) {
my $salary = $employee->salary;
next unless defined $salary;
if ( $salary < $threshold ) {
increase_salary( $employee, 3_000 );
}
}
}
##
##
use Unknown::Variables;
my $value = unknown;
my @array = ( 1, 2, 3, $value, 4, 5 );
my @less = grep { $_ < 4 } @array; # assigns (1,2,3)
my @greater = grep { $_ > 3 } @array; # assigns (4,5)
##
##
foreach my $employee (@employees) {
if ( $employee->salary < $threshold ) {
increase_salary( $employee, 3_000 );
}
}