system return value makes for strange logic
From: wana (ioneabu_at_yahoo.com)
Date: 10/29/04
- Next message: Anno Siegel: "Re: How do I check a valid mail address?"
- Previous message: Alan J. Flavell: "Re: Parsing 'dirty/corrupt data'. Advice wanted"
- Next in thread: Chris Cole: "Re: system return value makes for strange logic"
- Reply: Chris Cole: "Re: system return value makes for strange logic"
- Reply: Eric Bohlman: "Re: system return value makes for strange logic"
- Reply: Jürgen Exner: "Re: system return value makes for strange logic"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 29 Oct 2004 11:25:35 -0400
I was writing a short script to create a mysql database and kept getting
confusing results:
system("mysqladmin --user='$user' --password='$pass' create $db")
or die "$db not created due to error\n";
The function lead to die being called and printing the error message but the
database was being created successfully. I changed it to:
system("mysqladmin --user='$user' --password='$pass' create $db")
and die "$db not created due to error\n";
and even though it doesn't look right at first glance, it makes sense
because system apparently returns 0 with success and numbers > 0 for
failure. I read about it in 'Programming Perl' and saw the explanation
that the return value gives information about the nature of the failure.
Isn't this strange? Don't we normally look to $! for errors and consider 0
to mean failure? I can accept it, but 'do and die' sounds funny compared
to the usual 'do or die'.
wana
- Next message: Anno Siegel: "Re: How do I check a valid mail address?"
- Previous message: Alan J. Flavell: "Re: Parsing 'dirty/corrupt data'. Advice wanted"
- Next in thread: Chris Cole: "Re: system return value makes for strange logic"
- Reply: Chris Cole: "Re: system return value makes for strange logic"
- Reply: Eric Bohlman: "Re: system return value makes for strange logic"
- Reply: Jürgen Exner: "Re: system return value makes for strange logic"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|