#!/usr/athena/bin/perl
use strict;
use warnings;
my @lines = `cat /etc/passwd`;
foreach my $line (@lines) {
my @fields = split(':',$line);
if ($fields[2] < 100) {
print "$fields[0]\n";
}
}
#!/usr/athena/bin/perl
use strict;
use warnings;
my @lines = `cat /etc/passwd`;
my @keep = ();
foreach my $line (@lines) {
my @fields = split(':',$line);
if ($fields[2] < 100) {
push(@keep,$fields[0]);
}
}
@keep = sort @keep;
print "@keep\n";
#!/usr/athena/bin/perl
use strict;
use warnings;
my $file = `cat /etc/passwd`;
my @lines = split("\n",$file);
my $sum = 0;
foreach my $line (@lines) {
my @fields = split(':',$line);
$sum += $fields[3];
}
print "Sum is $sum\n";
#!/usr/athena/bin/perl
use strict;
use warnings;
my @users = qw(alice bob joe);
my $uid = 100;
foreach (@users) {
my @pwdentry = ($_,'x',$uid++,100,$_,"/home/$_","/bin/bash");
print join(":",@pwdentry)."\n";
}