in reply to Eval and system()
You are working just fine with eval ... it's system (specifically on Unix) that's tripping you up. Try doing:
Unix commands are built off of the C libraries (for the most part). The standard C libraries, for reasons which will be left to your imagination, use '0' to indicate success and non-zero to indicate failure. Thus, the Unix commands tend to follow this (rather stupid) paradigm.eval { system "fake command" && print "Blah1\n" }; eval { system "fake command" || print "Blah2\n" }; eval { system "ls" && print "Blah3\n" }; eval { system "ls" || print "Blah4\n" };
In addition, system handles all the cleanup from failed commands. If you want to test $@, try
Try them both - they exhibit different behaviors of eval and die.eval { die "Hello!\n" }; print "Reason: $@\n"; eval { die "Hello!" }; print "Reason: $@\n";
------
We are the carpenters and bricklayers of the Information Age.
Vote paco for President!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2: Eval and system()
by tilly (Archbishop) on Sep 07, 2001 at 18:29 UTC | |
|
Re: Re: Eval and system()
by pmas (Hermit) on Sep 05, 2001 at 18:30 UTC | |
|
Re: Re: Eval and system()
by camelman (Sexton) on Sep 05, 2001 at 19:36 UTC | |
|
Re: Re: Eval and system()
by busunsl (Vicar) on Sep 05, 2001 at 17:29 UTC |