SPUG:Confused field parser seeks...

Aaron Paul kalistibot at yahoo.com
Fri May 23 18:43:13 CDT 2003


A little clarity.
 
This works as I expect it to:
 
my $var="nobody:x:99:99:Nobody:/:/sbin/nologin";

$var=~ /(.+):(.+):(.+):(.+):(.+):(.+):(.+)/;


print "$1  $2  $3  $3  $4  $5  $6  $7\n\n";

it prints nobody:x:99:99:Nobody:/:/sbin/nologin
 
This isn't working and I can't see what is broken
about it:
 
&get_newuid;
$entry =
"$user"."-"."$domain".":x:"."$newuid".":"."$newuid".":"."$first
$last"\.":"."/bin/false";
print "$newuid \n";
print "$entry \n";
 
sub get_newuid{
my @lines;
my $lastline;
my $olduid;
open (PASS,  $draft);
 
@lines = <PASS>;
close(PASS);
$lastline = pop(@lines);
print "lastline is $lastline \n";      
$lastline=~ /(.+):(.+):(.+):(.+):(.+):(.+):(.+)/;
print "here are values $1  $2  $3  $3  $4  $5 $6 $7
\n\n";
$olduid = $4;
$newuid = ++$olduid;
 

return $newuid;
}
# eof
#
 
these values end up (un?)set to null/0:   $1  $2  $3 
$3  $4  $5 $6 $7 \n\n";

So in the end, $newuid is 1 instead of the incremented
value of the third colon seperated field which is
$lastline.  $lastline is properly being set, but the
$n vars are not.  Please help.
 
Thanks,
-Aaron
 

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com



More information about the spug-list mailing list