Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: boolean IN(); function in perl like

by blazar (Canon)
on Jan 16, 2005 at 16:09 UTC ( [id://422627]=note: print w/replies, xml ) Need Help??


in reply to boolean IN(); function in perl like

I suspect that adding my cmt so late will not add to its visibility however a solution that I find to be semantically appealing is along the lines of:
#!/usr/bin/perl -l use strict; use warnings; sub is { bless \shift, '_ghgh'; } sub _ghgh::in { my $x=${ shift, }; $x eq $_ and return 1 for @_; 0; } print is($_)->in(qw/foo bar baz/) ? 'yes' : 'no' for qw/bar fred/; __END__

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-18 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found