SPUG:Confused field parser seeks...
John Subaykan
cansubaykan at hotmail.com
Fri May 23 19:24:16 CDT 2003
It looks like the line where you construct $entry, you end up with a :
separated string of 6 things, but your pattern is trying to capture 7
things.
In other words, you have 5 colons in $entry (and subsequently in
$lastline??) but 6 colons in your pattern. (in your $var, you have a slash
that you don't have in $entry)
replace the line: $lastline=~ /(.+):(.+):(.+):(.+):(.+):(.+):(.+)/;
with:
if ($lastline=~ /(.+):(.+):(.+):(.+):(.+):(.+):(.+)/) {
print "match ok\n";
} else {
print "did not match\n";
}
to see that your pattern match is failing. or else, what exactly does
$lastline get set to?
----Original Message Follows----
From: Aaron Paul <kalistibot at yahoo.com>
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
_____________________________________________________________
Seattle Perl Users Group Mailing List
POST TO: spug-list at mail.pm.org
ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
MEETINGS: 3rd Tuesdays, U-District, Seattle WA
WEB PAGE: www.seattleperl.org
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
More information about the spug-list
mailing list