Help for this page

Select Code to Download


  1. or download this
    $ 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
    
  2. or download this
    foreach my $employee (@employees) {
        if ( $employee->salary < $threshold ) {
            increase_salary( $employee, 3_000 );
        }
    }
    
  3. or download this
    if ( defined $threshold ) {
        foreach my $employee (@employees) {
    ...
            }
        }
    }
    
  4. or download this
    use Unknown::Variables;
    
    ...
    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)
    
  5. or download this
    foreach my $employee (@employees) {
        if ( $employee->salary < $threshold ) {
            increase_salary( $employee, 3_000 );
        }
    }