Hello,
I've a doubt with getpwent function.
The following code [ getpwent in list context ] is getting into an infinite loop:
#!/usr/bin/perl -l
while ($ref = [ getpwent() ]) {
print $ref->[0];
}
Actually its printing the list before going into infinite loop.
when i tried the below code [ getpwent in scalar context ], it just works fine :
#!/usr/bin/perl -l
while ($ref = getpwen()) {
print $ref;
}
If i want getpwent in list context, I had to do this :
#!/usr/bin/perl -l
while ($ref = [ getpwent() ]) {
last unless @$ref;
print $ref->[0];
}
Can someone explain for this behaviour of getpwent?
Has it got anything to do with the return value while invoking
getpwent in scalar and list context?
--
/binish/
|
- problems with getpwent Binish A R
-