in reply to Re: Another perl battleship
in thread Another perl battleship

Excellent review (++). Permit me to make just one more tiny DRY suggestion to turn

# Ships - surely there is a better way to do this my %p1ships = ( cru => { hp => 2, size => 3, ap => 1, loc => '', sym => '*', mc = +> 0 }, car => { hp => 3, size => 5, ap => 2, loc => '', sym => '@', mc = +> 0 }, subm => { hp => 1, size => 2, ap => 3, loc => '', sym => '~', mc = +> 0 }, ); my %p2ships = ( cru => { hp => 2, size => 3, ap => 1, loc => '', sym => '*', mc = +> 0 }, car => { hp => 3, size => 5, ap => 2, loc => '', sym => '@', mc = +> 0 }, subm => { hp => 1, size => 2, ap => 3, loc => '', sym => '~', mc = +> 0 }, );

into

# Ships sub ships_init { return ( cru => { hp => 2, size => 3, ap => 1, loc => '', sym => '*', +mc => 0 }, car => { hp => 3, size => 5, ap => 2, loc => '', sym => '@', +mc => 0 }, subm => { hp => 1, size => 2, ap => 3, loc => '', sym => '~', +mc => 0 }, ); } my %p1ships = ships_init (); my %p2ships = ships_init ();