[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ISDN one more time, and an off-topic (perl) question.
- To: Oded Arbel <odeda-linux-il(at-nospam)betalfa.org.il>
- Subject: Re: ISDN one more time, and an off-topic (perl) question.
- From: Shlomi Fish <shlomif(at-nospam)techst02.technion.ac.il>
- Date: Sun, 25 Mar 2001 12:55:30 +0200 (IST)
- Cc: Linux-IL mailing list <linux-il(at-nospam)cs.huji.ac.il>
- In-Reply-To: <000b01c0b509$98553cf0$2900000a@oded>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
On Sun, 25 Mar 2001, Oded Arbel wrote:
> Hi list!
>
> I have a simple perl question, if you please :
> I have a function that needs to return a hash (%) to the caller - it does so
> something like this :
> <snip>
> return %temp;
> </snip>
> and I call it like this :
> <snip>
> %result = subname(params);
> </snip>
> now, I want to detect when that functin fails completly, so - when it does
> this, it returns a non-defined value :
> <snip>
> return undef.
> </snip>
> and now when I try to detect it :
> <snip>
> if (!defined %result) {
> </snip>
> it ofcourse doesn't work. so my question is - how should I try to detect the
> undefined value ?
>
I advise you to pass the Hash as a reference. Like this:
sub myfunc
{
...
return \%temp;
}
And then
$hash_ref = myfunc();
Then you can check if $hash_ref is undef. If it's not: you can dereference
it into a hash:
%hash = %{$hash_ref};
For more information consult the perlref manpage.
Hope it helps.
Shlomi Fish
----------------------------------------------------------------------
Shlomi Fish shlomif@t2.technion.ac.il
Home Page: http://t2.technion.ac.il/~shlomif/
Home E-mail: shlomif@techie.com
The prefix "God Said" has the extraordinary logical property of
converting any statement that follows it into a true one.
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il