This example is just creating a hash. There isn't really a "test" inside the map code. It just returns a list of values: first the word (e.g. q quit bye exit) and secondly 1. So you end up with a hash like
( q => 1, quit => 1, bye => 1, etc...) If this example used grep rather than map, then I would consider it a "test". Justin On Sat, 10 Dec 2005, Bob Clancy wrote: > URL from safari.oreilly.com: > http://safari.oreilly.com/?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0596001738/perlbp-CHP-4-SECT-18&k=null&g=&catid=&s=1&b=1&f=1&t=1&c=1&u=1&r=&o=1&n=1&d=1&p=1&a=0&page=0 > > I came couldn't figure out what a fat comma would > mean in a test inside a map block. Is this a typo > (possibly meaning "(#_ >= 1)" instead) or is there > something here that I just don't understand? > > > Readonly my %IS_EXIT_WORD > > => map { ($_ => 1) } qw( > > q quit bye exit stop done last finish aurevoir > > ); > > More details of the context from the page are shown > below (I added a "# CONFUSED_HERE" comment below the line in question.): > > Section: 4.18. List Membership > > ... > But don't use any( ) if your list membership test uses eq: > > Readonly my @EXIT_WORDS => qw( > q quit bye exit stop done last finish aurevoir > ); > > # and later... > > if ( any { $cmd eq $_ } @EXIT_WORDS ) { > abort_run( ); > } > > > In such cases it's much better to use a look-up table instead: > > > Readonly my %IS_EXIT_WORD > => map { ($_ => 1) } qw( > # CONFUSED_HERE: ^^^^^^^ > > q quit bye exit stop done last finish aurevoir > ); > > > > # and later... > > > > if ( $IS_EXIT_WORD{$cmd} ) { > abort_run( ); > } > > > > -- > -- thanks, Bob Clancy > -- > > _______________________________________________ > Boston-pm mailing list > [email protected] > http://mail.pm.org/mailman/listinfo/boston-pm > _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

