barnowl_perlaim
Last change
on this file since 7a1c90d was
7a1c90d,
checked in by Geoffrey Thomas <geofft@mit.edu>, 17 years ago
|
Skeleton AIM module, and Net::OSCAR 1.925
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | =pod |
---|
2 | |
---|
3 | Net::OSCAR::Screenname -- OSCAR screenname class |
---|
4 | |
---|
5 | This class overrides a few operators to transparently get |
---|
6 | appropriate behavior for OSCAR screennames. Screennames |
---|
7 | are case-insensitive and whitespace-insensitive. So, if you |
---|
8 | do |
---|
9 | $a = Net::OSCAR::Screenname->new("Some Dude"); |
---|
10 | print "Yay!\n" if $a eq "somedude"; |
---|
11 | will be true. |
---|
12 | |
---|
13 | =cut |
---|
14 | |
---|
15 | package Net::OSCAR::Screenname; |
---|
16 | |
---|
17 | $VERSION = '1.925'; |
---|
18 | $REVISION = '$Revision: 1.24 $'; |
---|
19 | |
---|
20 | use strict; |
---|
21 | use vars qw($VERSION); |
---|
22 | |
---|
23 | use Net::OSCAR::Utility qw(normalize); |
---|
24 | |
---|
25 | use overload |
---|
26 | "cmp" => "compare", |
---|
27 | '""' => "stringify", |
---|
28 | "bool" => "boolify"; |
---|
29 | |
---|
30 | sub new($$) { |
---|
31 | return $_[1] if ref($_[0]) or UNIVERSAL::isa($_[1], "Net::OSCAR::Screenname"); |
---|
32 | my $class = ref($_[0]) || $_[0] || "Net::OSCAR::Screenname"; |
---|
33 | shift; |
---|
34 | my $name = $_[0]; |
---|
35 | my $self = ref($name) eq "SCALAR" ? $name : \"$name"; |
---|
36 | bless $self, $class; |
---|
37 | return $self; |
---|
38 | } |
---|
39 | |
---|
40 | sub compare { |
---|
41 | my($self, $comparand) = @_; |
---|
42 | |
---|
43 | return normalize($$self) cmp normalize($comparand); |
---|
44 | } |
---|
45 | |
---|
46 | sub stringify { my $self = shift; return $$self; } |
---|
47 | |
---|
48 | sub boolify { |
---|
49 | my $self = shift; |
---|
50 | return 0 if !defined($$self) or $$self eq "" or $$self eq "0"; |
---|
51 | return 1; |
---|
52 | } |
---|
53 | |
---|
54 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.