in reply to Re^3: Values passed into a sub routine
in thread Values passed into a sub routine

No, 0 and undef are not always the same. Take 'fork' as an example:
Does a fork(2) system call to create a new process running the same program at the same point. It returns the child pid to the parent process, 0 to the child process, or undef if the fork is unsuccessful.
So 0 indicates it is a child process while undef indicates failure. Not the same.

In general, you should be checking for definedness if your data is coming from outside of the script anyway. I usually do something like 'if( defined $foo && $foo ne ""){}' That way I avoid warnings about doing a string comparison with an undefined value (or whatever the warning message says). You are using 'strict' and 'warnings', right?

Anyway, your code above looks good.

Elda Taluta; Sarks Sark; Ark Arks

Replies are listed 'Best First'.
Re^5: Values passed into a sub routine
by wallisds (Beadle) on Apr 21, 2011 at 13:13 UTC

    I think I have a clearer understanding of 0 vs undef now, thanks!

    Q - You are using 'strict' and 'warnings', right?
    A - Yes.