On Monday 28 Feb 2005 18:34, John W. Krahn wrote:
> Gavin Henry wrote:
> > Hi all,
>
> Hello,
>
> > Just a quickie. I think the answer is that th while loop is going through
> > the file twice?
> >
> > --------------
> > Codes that does what I expect, i.e. prints out the 42 lines of my passwd
> > file, with the array spaces, due to the array in "", swapped for <was :>
> > and runs on $_:
> >
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
> >
> > $" = '<was :>';
> >
> > open PASSWD, "/etc/passwd"
> >   or die "Eh? ($!)";
> >
> > while (<PASSWD>) {
> > my @passwds = split /:/;
> > print "@passwds";
> > }
>
> You could also do that with Perl's built-in functions:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> $" = '<was :>';
>
> setpwent;
> while ( my @passwds = getpwent ) {
>      print "@passwds";
>      }
> endpwent;

I'll do a:

perldoc -f setpwent 

and have a read



>
> John
> --
> use Perl;
> program
> fulfillment

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

-- 
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