in reply to Re: Read and parse text file
in thread Read and parse text file
Thanks again for your help earlier. I was wondering if there was a way to have this script read each line in a file and if there is not a fourth column, do not write that line out. If there is a fourth column, then write the line out. Thanks, RCP#!perl open (FILEH, "/etc/passwd"); #open the file for read while (<FILEH>) { #while there are still lines in FILEH... chomp; #clear newlines... if ( /root/i ) { # if line contains "root" case insensitive` ($username,$id) = (split /:/)[0,2]; #pull out field one and th +ree print "User: $username, ID: $id\n"; #print junk } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Read and parse text file
by Roy Johnson (Monsignor) on Mar 08, 2004 at 18:28 UTC | |
by RCP (Acolyte) on Mar 09, 2004 at 14:36 UTC |