Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Judging by the errors, my code is in a complete mess:#! /usr/bin/perl -wT use strict; # where grab account details from file goes my $username = 'bob'; my $realname = 'Bob The Great'; my $emailadd = 'a@b.com'; my $service = 'Yes'; my $ipaddr = '1.2.3.4'; my $file = 'nothing'; # Sanitise Passed Variables if ($realname !~ /^[-.\w\s]{3,30}$/) { # unlink $file; print "Realname Invalid\n"; exit; } if ($username !~ /^[A-Za-z][-.\w]{2,29}) { # unlink $file; print "Username Invalid\n"; exit; } # Generate Random Password And Encrypt It my @chars = ('a'..'z', 'A'..'Z', 0..9); my $password = do {{ local $_ = join "" => map {$chars [rand @chars]} 1..8; redo unless /[a-z]/ && /[A-Z]/ && /\d/; $_; }}; my $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]; my $encrpass = crypt($password, $salt); #Take Current System Date And Add Two Weeks On For Trial use constant WEEK => 60 * 60 * 24 * 7; my $expires = sprintf '%04d-%02d-%02d', sub { $_[5]+1900, $_[4]+1, $_[3] }->(localtime(time + 2 * WEEK)); # Create Unix User Account # Do Stuff Here
In string, @chars now must be written as \@chars at ./adduser.pl line +22, near "$file; print "Username Invalid\n"; exit; } # Generate Random Password And Encrypt It my @chars" Global symbol "@chars" requires explicit package name at ./adduser.pl +line 22. Global symbol "$password" requires explicit package name at ./adduser. +pl line 22. Global symbol "$chars" requires explicit package name at ./adduser.pl +line 22. In string, @chars now must be written as \@chars at ./adduser.pl line +22, near "$chars [rand @chars" Global symbol "@chars" requires explicit package name at ./adduser.pl +line 22. syntax error at ./adduser.pl line 33, near "redo unless /[" (Might be a runaway multi-line // string starting on line 22) Unmatched right curly bracket at ./adduser.pl line 35, at end of line syntax error at ./adduser.pl line 35, near "}" Execution of ./adduser.pl aborted due to compilation errors.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Whats Wrong Here?!?!
by jmcnamara (Monsignor) on Sep 12, 2002 at 10:26 UTC | |
by Anonymous Monk on Sep 12, 2002 at 10:28 UTC | |
by BrowserUk (Patriarch) on Sep 12, 2002 at 10:36 UTC | |
by George_Sherston (Vicar) on Sep 12, 2002 at 14:27 UTC | |
by spaz (Pilgrim) on Sep 12, 2002 at 18:44 UTC | |
Re: Whats Wrong Here?!?!
by Anonymous Monk on Apr 22, 2016 at 17:26 UTC |