Uri wrote:
isa
is a key valid? (not same as in a set).
isa usually works on fixed sets of keys
Well, in a strict sense it IS the same, as it is just one
of many possible set operations. I suppose you could say
it's a subset of sets. :-) I think you're trying to focus
on the
JDP == John Douglas Porter [EMAIL PROTECTED] writes:
JDP Uri wrote:
isa
is a key valid? (not same as in a set).
isa usually works on fixed sets of keys
JDP Well, in a strict sense it IS the same, as it is just one
JDP of many possible set operations. I suppose you could say
Jerrad Pierce wrote:
How about using a hash to keep track of which things you've already handled?
That's just the afore-mentioned count
True, I guess, but lots of these uses are the same. In Uri's original
post, isa could be considered the same as sets, and records the
same as data
Don't know if this falls into categories already
covered (set of active objects in a class? counting?),
but I often find a hash of open filehandles useful. e.g. to
divide a big file into several smaller ones, using the
distinct values of one of the fields as filenames :
perl -MIO::File -ane
s == shmem [EMAIL PROTECTED] writes:
s You forgot an obscure corner of hashes: hashes in scalar context.
s Here's a a use - calculate the next power of 2 of a given number:
s sub next_power_of_two {
s my %s;
s @s{1..shift} = ();
s %s =~ '/';
s return $';
s }
KI == Keith Ivey [EMAIL PROTECTED] writes:
KI Jerrad Pierce wrote:
How about using a hash to keep track of which things you've already
handled?
That's just the afore-mentioned count
KI True, I guess, but lots of these uses are the same. In Uri's original
KI post, isa could be
Uri wrote:
i still think isa is a (sic) concept that is important enough to
cover on its own. sure it is a set but a very specific type
with its own name. the names of these concepts are important
(almost like design patterns which i despise :).
If names are that important to you, then you
Uri Guttman writes:
AP == A Pagaltzis [EMAIL PROTECTED] writes:
AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
AP ( $dispatch{$sub} || sub { warn no such action '$sub'
On 23 Nov 2007 at 23:54, Uri Guttman wrote:
SHC == Shawn H Corey [EMAIL PROTECTED] writes:
SHC Vladi Belperchinov-Shabanski wrote:
On Fri, 23 Nov 2007 23:18:20 +0100
A. Pagaltzis [EMAIL PROTECTED] wrote:
* Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists(
* David Landgren [EMAIL PROTECTED] [2007-11-24 10:45]:
Uri Guttman writes:
AP == A Pagaltzis [EMAIL PROTECTED] writes:
AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
AP
On Sat, 24 Nov 2007 10:43:58 +0100
David Landgren [EMAIL PROTECTED] wrote:
Uri Guttman writes:
AP == A Pagaltzis [EMAIL PROTECTED] writes:
AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in
DL == David Landgren [EMAIL PROTECTED] writes:
DL Uri Guttman writes:
AP == A Pagaltzis [EMAIL PROTECTED] writes:
AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
AP (
Uri Guttman writes:
DL Why stop there? Assuming $key never evaluates to 0:
DLmy $sub = $dispatch{ $key || 'default' };
and what if $key is true but not found?? that is a different
problem. your code doesn't handle that, it only handles a false or missing key
DL If it does, wait
DL == David Landgren [EMAIL PROTECTED] writes:
DL Although there really is little point stuffing the coderef into a
DL scalar, it's not like there's anything you can do to it. It's clearer to
DL not draw attention to it and just run the damned thing:
DL $dispatch{ $key || 'default' }-();
SF == Steve Fink [EMAIL PROTECTED] writes:
SF I don't think this has been mentioned, although it's really just a
SF combination of two existing ones: I often have a table of sets.
SF for my $user (@filenames) {
SF open(my $fh, , $user) {
SF while($fh) {
SF
How about using a hash to keep track of which things you've already handled?
my %seen;
for my $value (@values) {
next if $seen{$value}++;
# Do processing with $value here.
}
--
Keith C. Ivey [EMAIL PROTECTED]
Washington, DC
How about using a hash to keep track of which things you've already handled?
That's just the afore-mentioned count
--
Free map of local environmental resources: http://CambridgeMA.GreenMap.org
--
MOTD on Pungenday, the 36th of The Aftermath, in the YOLD 3173:
Wibble.
On Friday, Nov 23rd 2007 at 14:53 -, quoth Jerrad Pierce:
=I admit I'm better with python these days than I am with perl, but one of
=the caveats that the dispatch table should be taught with is that
=selecting the correct code ref is different from calling through it.
=
=You might want to
AP == A Pagaltzis [EMAIL PROTECTED] writes:
AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
AP ( $dispatch{$sub} || sub { warn no such action '$sub' } )-();
some
A. Pagaltzis wrote:
* Mr. Shawn H. Corey [EMAIL PROTECTED] [2007-11-24 00:50]:
my $sub = ( exists $dispatch{ $key } ref( $dispatch{ $key } ) eq 'CODE' )
? $dispatch{ $key }
: $dispatch{ 'default' };
Just because you're not paranoid doesn't mean computers don't
hate you :)
Tied hashes a la Regexp::Common.
On Fri, 23 Nov 2007 23:18:20 +0100
A. Pagaltzis [EMAIL PROTECTED] wrote:
* Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
( $dispatch{$sub} || sub { warn no such action
SHC == Shawn H Corey [EMAIL PROTECTED] writes:
SHC Vladi Belperchinov-Shabanski wrote:
On Fri, 23 Nov 2007 23:18:20 +0100
A. Pagaltzis [EMAIL PROTECTED] wrote:
* Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key
* Mr. Shawn H. Corey [EMAIL PROTECTED] [2007-11-24 00:50]:
my $sub = ( exists $dispatch{ $key } ref( $dispatch{ $key } ) eq 'CODE' )
? $dispatch{ $key }
: $dispatch{ 'default' };
Just because you're not paranoid doesn't mean computers don't
hate you :)
So why did you skip
Steven W. Orr wrote:
On Friday, Nov 23rd 2007 at 14:53 -, quoth Jerrad Pierce:
=I admit I'm better with python these days than I am with perl, but one of
=the caveats that the dispatch table should be taught with is that
=selecting the correct code ref is different from calling through it.
on Friday, Nov 23rd 2007 at 13:12 -, quoth Uri Guttman:
=
=too long has this list been quiet. but i have a fun question. i am
=writing up slides for an all about hashes class. one goal i have is to
=list and explain as many different uses for hashes as reasonably
=possible. i have a short
Uri Guttman wrote:
too long has this list been quiet. but i have a fun question. i am
writing up slides for an all about hashes class. one goal i have is to
list and explain as many different uses for hashes as reasonably
possible. i have a short list to start with but i am sure the hive mind
of
On Fri, Nov 23, 2007 at 01:12:37PM -0500, Uri Guttman wrote:
isa
is a key valid? (not same as in a set). isa usually works on
fixed sets of keys
my @foos = qw( axxj djdj whwh ) ;
my %is_a_foo = map { $_ = 1 } @foos
I don't have
* Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
( $dispatch{$sub} || sub { warn no such action '$sub' } )-();
--
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined
SW == Scott Wiersdorf [EMAIL PROTECTED] writes:
SW I don't have any additional uses for hashes to add, but I do have a
SW great hash initializer I picked up from Damian when he was in town a
SW few years ago (borrowing from your example):
SW my @foos = qw( axxj djdj whwh ) ;
SW my
Uri Guttman wrote:
AP == A Pagaltzis [EMAIL PROTECTED] writes:
AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
AP ( $dispatch{$sub} || sub { warn no such action '$sub' }
31 matches
Mail list logo