in reply to Is it possible to store an arthimetric operator in a variable?
Sure:
Edit: mrborisguy beat me to this answer while I was contemplating using tie to do it.sub _eq($$){ $_[0] == $_[1] ? 1 : 0 } sub _ne($$){ $_[0] == $_[1] ? 0 : 1 } my $op = \&_eq; print $op->( 1, 2 ) ? 'EQ' : 'NEQ'";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Is it possible to store an arthimetric operator in a variable?
by ikegami (Patriarch) on Jul 19, 2005 at 14:46 UTC | |
by Adam (Vicar) on Jul 19, 2005 at 15:18 UTC | |
by ikegami (Patriarch) on Jul 19, 2005 at 15:22 UTC | |
by Adam (Vicar) on Jul 19, 2005 at 15:23 UTC | |
by benizi (Hermit) on Jul 20, 2005 at 19:17 UTC | |
Re^2: Is it possible to store an arthimetric operator in a variable?
by Adam (Vicar) on Jul 19, 2005 at 17:27 UTC |
In Section
Seekers of Perl Wisdom