[comp.lang.perl] Chapter 6 passwd program problem

ramsey@NPIRS.Purdue.EDU (Ed Ramsey) (02/06/91)

I liked the "Programming Perl" approach to setting user passwords and
downloaded the book sources last night.  The source for the
chapter 6 password program complains at two points in the code.

fieldofdreams 438 ### perl -v

This is perl, version 3.0

$Header: perly.c,v 3.0.1.10 91/01/11 18:22:48 lwall Locked $
Patch level: 44

Copyright (c) 1989, 1990, Larry Wall

Perl may be copied only under the terms of the GNU General Public License,
a copy of which can be found with the Perl 3.0 distribution kit.
fieldofdreams 441 ### ./passwd
syntax error in file ./passwd at line 250, next token "open"
/^(jan|feb|mar(ch)?|apr(il)?|may|june?/: unmatched () in regexp at ./passwd line 647.

Any suggestions?

-Ed

-- 

Ed Ramsey   ramsey@npirs.purdue.edu     317/494-6616     fax 317/494-0535
There is nothing more important to me than knowing Jesus as He really is.

merlyn@iwarp.intel.com (Randal L. Schwartz) (02/06/91)

In article <1991Feb5.210926.7914@NPIRS.Purdue.EDU>, ramsey@NPIRS (Ed Ramsey) writes:
| fieldofdreams 441 ### ./passwd
| syntax error in file ./passwd at line 250, next token "open"
| /^(jan|feb|mar(ch)?|apr(il)?|may|june?/: unmatched () in regexp at ./passwd line 647.
| 
| Any suggestions?

Yeah.  It's a syntax error, and therefore, a typo.  It looks like
it crept in when we folded a long line into two pieces.  Change those
two lines to read:

      ($mo =~ /^(jan|feb|mar(ch)?|apr(il)?|may|june?)$/i ||
       $mo =~ /^(july?|aug|sept?|oct|nov|dec)$/i) ) {

and be sure to send in the reader-comment card in the back. :-)

print "Just another Perl book hacker,"
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/

rbj@uunet.UU.NET (Root Boy Jim) (02/06/91)

In article <1991Feb5.210926.7914@NPIRS.Purdue.EDU> ramsey@NPIRS.Purdue.EDU (Ed Ramsey) writes:
>I liked the "Programming Perl" approach to setting user passwords and
>downloaded the book sources last night.  The source for the
>chapter 6 password program complains at two points in the code.

That's cuz it's broke.

>syntax error in file ./passwd at line 250, next token "open"

Missing ';' on the previous line.

>/^(jan|feb|mar(ch)?|apr(il)?|may|june?/: unmatched ()
> in regexp at ./passwd line 647.

Looks like the line was split. It should read:

	/^(jan|...|june?)$/

And the RE on the next line should read:

	/^(july?|...|dec)$/

I am still skeptical of the assignment to $mo.
I believe it should be @mo, and the following
tests should be performed on $mo[0]. Either that,
or $mo = ($pat =~ /...(...).../)[0] will work.

I would have done the match outside the if and
used $1 instead of $mo.

Job's .signature: &rebuke("\b","\b\bjust another perl hacker");
-- 

	Root Boy Jim Cottrell <rbj@uunet.uu.net>
	I got a head full of ideas
	They're driving me insane