Mailing List Archive

perl 5.001m syntax error
Firstly, I have just installed 5.001m and have NO previous experience
of perl, but as the script I have a problem with is taken from
Programming Perl (so I'm told - I can't get hold of a copy
immediately), I imagine that this is a Perl 5 issue. I Have had a hunt
in the documentation, but there's rather a lot of it and I've been
told to get this working asap. Enough of my whingeing - the script is
the password checking one from the above book, and line 250:

open(PASSWD,"passwd") || die "Can't open passwd file.\n";

is rejected with

syntax error at perlpass line 250, near "open"

I have played around, but without success.

Whilst I'm here, I also had a problem with unmatched parentheses
reported for line 647:

if ($mo = ($pass =~ /^[ \d]*([a-zA-Z]{3,5})[ \d]*$/) &&
($mo =~ /^(jan|feb|mar(ch)?|apr(il)?|may|june?/i ||
$mo =~|july?|aug|sept?|oct|nov|dec)$/i) ) {
print "Please don't use dates.\n";

647 is the second of the above lines. I got round this by making the
test for months into one long line - after checking (by eyeball and
vi) that the parens were in fact matched.

Any suggestions on either of these problems would be appreciated.

TIA, Sam
Re: perl 5.001m syntax error [ In reply to ]
On Mon, 30 Oct 1995, Sam Sexton 01203 256562 (24 742) wrote:

> $locked || die "/etc/passwd file busy--try again later.\n"
^-- ; surely?
>
> open(PASSWD,"passwd") || die "Can't open passwd file.\n";
> open(PTMP,">ptmp") || die "Can't copy passwd file.\n";

Mike

--
Mike Stok | The "`Stok' disclaimers" apply.
stok@pencom.com | Pencom Systems Administration (work)
stok@cybercom.net | Cyber Access (play)
http://www.cybercom.net/~stok/ | The inevitable WWW page (?)
Re: perl 5.001m syntax error [ In reply to ]
Strange sunspot activity caused Pete Peterson <rep@genrad.com> to write:
|
| Your second message reveals the "line 250" error:
|

Not to pick on Pete, but could we please reply to the originator on threads
like this. This list is getting way too much traffic as is (it very
difficult for me to keep up, and I *reallY* need to know what is going on,
so I can attempt to stay ahead of the development curve for the new Camel),
we need to find ways to remove some of it.

Thanks,
-spp
Re: perl 5.001m syntax error [ In reply to ]
Your second message reveals the "line 250" error:

> Date: Mon, 30 Oct 1995 15:04:46 -0500 (EST)
> From: "Sam Sexton 01203 256562 (24 742)" <sam.sexton@reuters.com>
> Subject: Re: perl 5.001m syntax error
> To: Mike Stok <stok@cybercom.net>
> Cc: perl5-porters@africa.nicoh.com
> X-Filter: mailagent [version 3.0 PL44] for rep@genrad.com
>
> >>
> >>What are the lines before this?
> >>
> Fair question - I should have included some context...
>
> # Now check again for a lock on the passwd file.
>
> if (-f 'ptmp') {
> print "Password file busy--waiting up to 60 seconds...\n";
> for ($i = 60; $i > 0; --$i) {
> sleep(1);
> print $i,'...';
> last unless -f 'ptmp';
> }
> }
> die "\n/etc/passwd file busy--try again later.\n" if -f 'ptmp';
>
> # Create the lock using link() for atomicity
>
> open(PTMP,">ptmptmp$$")
> || die "Can't create tmp passwd file.\n";
> close PTMP;
> $locked = link("ptmptmp$$",'ptmp');
> unlink "ptmptmp$$";
> $locked || die "/etc/passwd file busy--try again later.\n"

***************************
You're missing the semicolon at the end of the line above.
***************************

> open(PASSWD,"passwd") || die "Can't open passwd file.\n";
> open(PTMP,">ptmp") || die "Can't copy passwd file.\n";
>
> # Encrypt using salt that's fairly random but encodes weeks
> # since 1970, mod 64.
>
> # (We perturb the week using the first two chars of $me so
> # that if everyone changes their password the same week we
> # still get more than 64 possible salts.)
>
> $now = time;
>

pete peterson
rep@genrad.com
(508)287-7478; Home: (508)256-5829 (Chelmsford, MA)
Re: perl 5.001m syntax error [ In reply to ]
>>
>>What are the lines before this?
>>
Fair question - I should have included some context...

# Now check again for a lock on the passwd file.

if (-f 'ptmp') {
print "Password file busy--waiting up to 60 seconds...\n";
for ($i = 60; $i > 0; --$i) {
sleep(1);
print $i,'...';
last unless -f 'ptmp';
}
}
die "\n/etc/passwd file busy--try again later.\n" if -f 'ptmp';

# Create the lock using link() for atomicity

open(PTMP,">ptmptmp$$")
|| die "Can't create tmp passwd file.\n";
close PTMP;
$locked = link("ptmptmp$$",'ptmp');
unlink "ptmptmp$$";
$locked || die "/etc/passwd file busy--try again later.\n"

open(PASSWD,"passwd") || die "Can't open passwd file.\n";
open(PTMP,">ptmp") || die "Can't copy passwd file.\n";

# Encrypt using salt that's fairly random but encodes weeks
# since 1970, mod 64.

# (We perturb the week using the first two chars of $me so
# that if everyone changes their password the same week we
# still get more than 64 possible salts.)

$now = time;
($pert1, $pert2) = unpack("C2", $me);
$week = $now / (60*60*24*7) + $pert1 + $pert2 - $AGE;
Re: perl 5.001m syntax error [ In reply to ]
In <5446041530101995/A02301/UKIMS6/119AF3C42D00*@MHS>
On Mon, 30 Oct 1995 15:04:46 -0500 (EST)
Sam Sexton <sam.sexton@reuters.com> writes:
>unlink "ptmptmp$$";
>$locked || die "/etc/passwd file busy--try again later.\n"
^- missing ';'
>
>open(PASSWD,"passwd") || die "Can't open passwd file.\n";