in reply to __DIE__ easy CGI question
produces:#!/usr/bin/perl -w use strict; $SIG{__DIE__} = sub { print "redirecturl?error='@_'\n"; exit(1); }; die "3";
redirecturl?error='3 at /tmp/t112 line 10. '
The problem is that you also get a line number with your error message. You can either eliminate that with a regex, or you can use die "3\n" and then use chomp to eliminate the newline. The @_ variable is readonly, so you'll have to make a copy:
produces#!/usr/bin/perl -w use strict; $SIG{__DIE__} = sub { my $why = shift; $why =~ s/( at.*)?\n$//; print "redirecturl?error='$why'\n"; exit(1); }; die "3";
redirecturl?error='3'whether you use die "3" or die "3\n".
|
|---|