Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

•Re: Re: Checking and undef'in hash elements in one step?

by merlyn (Sage)
on Apr 16, 2003 at 03:11 UTC ( #250766=note: print w/replies, xml ) Need Help??


in reply to Re: Checking and undef'in hash elements in one step?
in thread One liner to Check and undef hash elements

print "no keys\n" unless( values(%hash) != NULL );
What programming language is that? Not Perl.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Re: Checking and undef'in hash elements in one step?
by feanor_269 (Beadle) on Apr 16, 2003 at 03:53 UTC
    Perhaps saying that NULL isn't a keyword would be more constructive, or that he meant undef instead.
    cb reference!:
    now, what are the odds I log in in the morning to find all my posts mysteriously downvoted?
    UPDATE:Awww. not downvoted at all.

    feanor_269
Re: •Re: Re: Checking and undef'in hash elements in one step?
by l2kashe (Deacon) on Apr 16, 2003 at 03:45 UTC
    It was more to display the idea .. but its syntax is correct and in testing provided acurate results.. I've now garnished quite a few negative XP for this nodelet.. Thanks for at least responding to the post...

    Now why dont people like this??

    should it have said "no values were defined?" which matches what was asked for?.. should I have left it as unless( values(%hash)) ???

    after testing some more I now see that the values(%hash) is sufficient.. I stand corrected and accept the negative XP..
    /me dohs and hangs his head in shame...

    MMMMM... Chocolaty Perl Goodness.....
Re: •Re: Re: Checking and undef'in hash elements in one step?
by pg (Canon) on Apr 16, 2003 at 03:50 UTC
    A Perl line with syntax error is still Perl.

    To be frank, I don't see the point of your last line, that Q&A. It should not be too difficult for people to be nice to each other. Make pointless comment (I point to your last line) is an insult to the merit of the poster, and the community at large. I don't see this funny at all.

    I read your disclaimer, but it does not entitle you to be rude, or gives you the excuse to be rude. Doesn't matter whether it is for a good purpose or a bad one, the way you expressed yourself is rude, and there is no need to put things in that way.

    I point out this to you for your benefit, to be sincere. I don't jump on you because of this single incident, but you have been doing this to people from time to time.

    Well, I understand how you behave yourself is really your decision.

Re: •Re: Re: Checking and undef'in hash elements in one step?
by pg (Canon) on Apr 16, 2003 at 05:16 UTC
    As you said the syntax is wrong, let me tell you now, from a pure syntax point of view, this is perfectly correct Perl syntax.

    Didn't you realize that NULL could be a constant?
    use strict; use constant NULL => ""; my @a = (1,2,3); my @b = (); my @c = (""); print "a is empty: " . is_null(@a), "\n"; print "b is empty: " . is_null(@b), "\n"; print "c is empty: " . is_null(@c); sub is_null { my @a = @_; (@a == NULL) ? "true" : "false"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://250766]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-01-17 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?