On Sun, Mar 30, 2008 at 10:56 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > > On Mar 30, 6:54 am, [EMAIL PROTECTED] (John W. Krahn) wrote: > >> > > >> die() exits the program. > >> > > Yes, I understand that die() exits the program. My question was are > > you able to process more than one line of code in a die() context? > > die(), like print() and warn(), prints a list of strings. To do what I > think you are trying to do: > > open my $FH, '<', 'somefile' or do { > # some statement here; > # and another statement; > # and finally; > die "some string here"; > > }; > snip
There are at least three ways to do this. The way above is good if this is something that needs to happen only on this error. If you always want a piece of code to run when an error occurs you can override the __DIE__ signal: $SIG{__DIE__} = sub { #do stuff like write to a log file } And if you need something to always run at the end of your program (regardless if there was an error or not), you can use an END block: END { print "This will always run at the end of the program, regardless of die() or exit()\n"; } -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/