Re: [SPOILER] Perl Quiz of the Week #24 (Turing Machine simulation)
Ronald J Kimball <[email protected]> Fri, 17 Sep 2004 10:52:28 -0400
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Sep 17, 2004 at 10:26:42AM -0400, Mark Jason Dominus wrote: > > > if (/^(\w+)\s+(\w)\s+(\w+)\s+(\w)\s+([LR])\s*$/) > > I'm surprised that all four of the sample solutions posted so far use > a complicated-looking regex like this instead of going for 'split', > seemed to me to be the obvious and straightforward technique. "Your program should die with an error message if it encounters a badly formatted line in the state transition instruction file." Using the regex you can validate the entire line at once. Ronald