Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

"undef" is not NULL and what to do about it

by Ovid (Cardinal)
on Feb 20, 2013 at 16:31 UTC ( #1019806=perlmeditation: print w/ replies, xml ) Need Help??

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 );
        }
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1019806]
Approved by marto
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2016-02-13 16:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (439 votes), past polls