|P is for Practical|
Re^2: Tk cryptogram (no, not cryptography)by graff (Chancellor)
|on Sep 24, 2009 at 02:31 UTC||Need Help??|
Thank you so much...
You're so welcome! I'm glad to see someone having fun with this. Do you happen to have a source of cryptograms in electronic form, such that you can extract input files for use with your version of the script? Or are you just using a text editor to create your input files? (I would have used my version more often if I didn't have to always type in the puzzle from the newspaper or puzzle book.)
If you're going to insist on having a puzzle file provided as a command-line arg, you can leave out the "Read File" button -- just call your "readFile" sub before you call MainLoop.
As for loading (a big or huge version of) a "dictionary" file that has been crafted in some strange and mysterious way, that seems like too much work -- there must be a way to just use a simple word list. I would point out that your format doesn't really need the initial "string length" field, since this is evident from the string itself.
I don't really understand what's going on with the patterns and the dictionary, but alas, I feel like you ought to be scolded about this part of your "doword" sub:
Apart from those comments being a waste, I think all those calls to substr could be replaced with something like this:
One other nit-pick, in the "extractTemplates" sub:
Notice how the "if" condition there can never return true, because all the spaces in the string have been removed by the previous "tr///"; meanwhile, you are able to push empty strings onto your @template array. Maybe you want it to be like this?
But I don't know what difference it makes in how things actually work. I noticed that if you hit the enter key more than once, you get extra spacing in some of the strings being displayed (but fixing that "if" condition didn't change this behavior). Anyway, good luck with that.