while is also easier to use to loop through a hash than a foreach
#foreach
foreach $keys (keys(%hash)) {
# gives you only keys. With values, the foreach loop
# gets even more complicated.
}
# while
while (($keys,$values) = each(%hash)) {
# lets you use both values of a hash...
I changed the code accordingly:
#!/usr/bin/perl -w
use strict;
use File::NCopy qw(copy);
my $oldserv = "./testing";
my $newserv = "./testing2";
my $usernumfile = "./usrbynum.txt";
my $usershortfile = "./srnames.txt";
my %finishedusers;
open USERNUMS, "< $usernumfile" or die "$!";
open...
OK, I've edited the code a bit more, using proper syntax with use strict. I am now getting a syntax error, and the script still wont work.
New Code:
#!/usr/bin/perl -w
use strict;
use File::NCopy qw(copy);
my $oldserv = "./testing";
my $newserv = "./testing2";
my $usernumfile =...
Please note that, although I am a student at this school, I am a friend with the sys admin, and I am helping with this merge for that reason. It is not homework (just thought I should clear any doubt, because I saw the note about homework).
My situation is this: My school used to have their student/faculty login system setup, so each user loged in with their full name "First Last". This 'full name' was actually a psydonym for the real UNIX username, which was u character, followed by 3-5 addititonal digits (ie u881).
We have since...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.