[Israel.pm] setting $!

Itzik Lerner - Orpak itzik at orpak.co.il
Mon Jul 19 06:18:14 PDT 2004

You can do:

	sub foo {
			if (fail) {
				my $err;
				$err='some error message';

But it will destroy $! After this action, so it is good only if you don't
use $! For anything else.

--Itzik Lerner


-----Original Message-----
From: Shlomo Yona [mailto:shlomo at cs.haifa.ac.il] 
Sent: Sunday, July 18, 2004 9:10 PM
To: perl at perl.org.il
Subject: [Israel.pm] setting $!


I have a function foo() which returns some scalar $s.

I'd like to be able to do something like this:

	my $s = foo() or die "foo: $!";

I'd like to  be able to assign my own string to $! to be
used right after a return from foo()  in case an undefined
value is returned.

What's the way to do this?

Shlomo Yona
shlomo at cs.haifa.ac.il
Perl mailing list
Perl at perl.org.il

More information about the Perl mailing list