--- Ela Jarecka <[EMAIL PROTECTED]> wrote:
> Hi folks,
> I have a couple of doubts/questions about the usage of above
> functions:
>
> 1. will those three always work the same ( I have troubles
> understanding the
> 'die' description in Llama book ( $!, $?>>8, the status of the last
> reaped child from a system, wait, close on a pipe, or `command`))?:
As an oversimplification that might help put things into perspective,
die() returns an error code and prints a message to STDERR. exit()
defaults to an ok exit code with no message.
> if ( ( $reqrec->fillServ($ServRef) ) == undef ) {
> print "fillRec failed! \n";
> exit;
> }
This error message likely goes to STDOUT, and the program exits with a
zero error status.
> if ( ( $reqrec->fillServ($ServRef) ) == undef ) {
> die "fillRec failed! \n";
> }
This error message likely goes to STDERR, and the program exits with a
nonzero status code.
> $reqrec->fillServ($ServRef) or die "fillServ failed";
This is the same as the previous except that in the block if you
specifically compared to undef, where here you're just testing for
boolean false (which could also be 0 or "").
> In fillServ function, I use 'return;' upon failure and 'return 1;' if
> everything is OK.
return() passes back undef with no args, so the tests should be
equivelent.
> 2. is it a matter of style to use 'not defined(_expression_)' or
> (_expression_) == undef? I get warnings in the second case..
== is a numeric comparison, which you don't want against undef.
I use "not defined" when I need to check specifically for undef, but
try to just use "not" when I'm sure of the return type.
> Will defined cover also an empty string?
An empty string ("") is defined, but false.
> Any comments will be greatly appreciated, as it is my first bigger
> program in Perl and I would like it to work flawless...
An admirable plan.
use strict and -w! =o)
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/