Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 exploiting the Monastery: (3)
As of 2014-09-22 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (177 votes), past polls