D
delfuego
Hello,
I am trying to write a simple Perl program to do the following:
Open /etc/passwd for read, create an output file in cwd for append,
cut the fields 1,3-4,6 from /etc/passwd and redirect that output to
the output file password, then close the two file handles for the
input and output files.
Here is the code:
#!/usr/bin/perl -w
#
my $FIN;
my $FOUT;
#
open ($FIN, "</etc/passwd") or die "Cannot open input file.\n";
open ($FOUT, ">>password") or die "Cannot open output file.\n";
#
while ($myline = <$FIN>) {
readline($FIN);
$myline=$printable;
print($FOUT,$printable,"\n");
i $myline = chop($myline = `cut -d: -f1,3-4,6`);
}
#
close ($FIN);
close ($FOUT);
#
Here is the error message:
[root@localhost james]# ./program.pl
Use of uninitialized value in print at ./program.pl line 12, <$FIN>
line 2.
GLOB(0x804ca88)
[root@localhost james]#
Thank you for your help.
James
I am trying to write a simple Perl program to do the following:
Open /etc/passwd for read, create an output file in cwd for append,
cut the fields 1,3-4,6 from /etc/passwd and redirect that output to
the output file password, then close the two file handles for the
input and output files.
Here is the code:
#!/usr/bin/perl -w
#
my $FIN;
my $FOUT;
#
open ($FIN, "</etc/passwd") or die "Cannot open input file.\n";
open ($FOUT, ">>password") or die "Cannot open output file.\n";
#
while ($myline = <$FIN>) {
readline($FIN);
$myline=$printable;
print($FOUT,$printable,"\n");
i $myline = chop($myline = `cut -d: -f1,3-4,6`);
}
#
close ($FIN);
close ($FOUT);
#
Here is the error message:
[root@localhost james]# ./program.pl
Use of uninitialized value in print at ./program.pl line 12, <$FIN>
line 2.
GLOB(0x804ca88)
[root@localhost james]#
Thank you for your help.
James