Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: A Semi-automatic word search solver

by CountZero (Bishop)
on Sep 26, 2009 at 07:03 UTC ( [id://797648]=note: print w/replies, xml ) Need Help??


in reply to A Semi-automatic word search solver

Here is a small subroutine (really only one line long) to make the building of your @puzzle array even easier.
use strict; use warnings; use Data::Dumper; my @puzzle = qw/abcde fghij klmno pqrst uvwxy/; @puzzle = make_puzzle(@puzzle); print Dumper(\@puzzle); sub make_puzzle{ return map{[split //, $_]} @_; }
One question if I may: Why are you using subroutine prototypes in your search subroutine?

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: A Semi-automatic word search solver
by The Hindmost (Scribe) on Sep 26, 2009 at 15:49 UTC
    Thanks for the subroutine, I think I will use that as part of the update I'm planning. As for using a prototype on the subroutine, I've always done it that way, but if this is considered incorrect or foolish, please do tell me.
      Prototypes in Perl are very special. They are not --as many people expect-- a tool to check at compile-time or even run-time wether the parameters of your subroutine call are correct. Have a look at Gratuitous use of Perl Prototypes, it explains clearly why Perl "prototypes" are totally different from (for example) C "prototypes".

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        Thanks, that does clear it up for me, coming from a C(++) background prototyping had just become a default behaviour like putting #!/usr/bin/perl at the top of every bit of perl code has.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://797648]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found