On Sat, Sep 17, 2005 at 08:20:55PM +0530 Binish A R wrote:
> 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() ]) {
>       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?

I am not an expert but this works fine for me:

#!/usr/bin/perl
#getpwent1.pl

while (@ref = getpwent()) {
        foreach $i (0..8) {
                print "$ref[$i]  "
        }
        print "\n";
}



hth
-- 
Gérard 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to