in reply to Die statement with text & formatting of the user
I would look as follows with a die statement:
do { local *STDERR = *STDOUT; $! = 0; die(h1( {class=>'cyan'}, "Error occured $row->{username}! Script ha +ve to die" )); } if $select->rows;
Of course, the following would be shorter:
do { print(h1( {class=>'cyan'}, "Error occured $row->{username}! Script +have to die" )); exit(0); } if $select->rows;
Even shorter:
print(h1( {class=>'cyan'}, "Error occured $row->{username}! Script hav +e to die" )), exit(0) if $select->rows;
The problem is neither is particularly readable. You might as well use
if ($select->rows) { print(h1( {class=>'cyan'}, "Error occured $row->{username}! Script +have to die" )); exit(0); }
There is a readable one-line, however:
sub fatal_error { print(h1( {class=>'cyan'}, @_); exit(0); } fatal_error("Error occured $row->{username}! Script have to die") if $select->rows;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Merge 2 lines in 1 die statement
by Nik (Initiate) on Apr 28, 2007 at 07:52 UTC | |
by shmem (Chancellor) on Apr 28, 2007 at 09:30 UTC | |
by Nik (Initiate) on Apr 28, 2007 at 09:39 UTC | |
by shmem (Chancellor) on Apr 28, 2007 at 11:00 UTC | |
by ikegami (Patriarch) on Apr 28, 2007 at 15:44 UTC | |
by Nik (Initiate) on Apr 28, 2007 at 11:33 UTC | |
| |
|
Re^2: Merge 2 lines in 1 die statement
by Nik (Initiate) on Apr 28, 2007 at 10:10 UTC | |
by rhesa (Vicar) on Apr 28, 2007 at 13:35 UTC |