Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by Ovid (Cardinal)
on Feb 20, 2013 at 16:31 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-20 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found