Stuart Clemons wrote:
> 
> Hi all:

Hello,

> I'm trying to cleanup and format this text file of user names, so that I
> have one column of user names.  Here's the text file:
> 
> The request will be processed at a domain controller for domain FOOBAR.
> 
> Group name      Misc
> Comment        These are the FOOBAR users
> 
> Members
> 
> -------------------------------------------------------------------------------
> arod                     cschilling               csenior
> ecostello                ffrank                   gbennett
> LBird                    PMartinez
> The command completed successfully.
> 
> I would like an output file to read like this:
> 
> arod
> cschilling
> csenior
> ecostello
> ffrank
> gbennett
> LBird
> PMartinez
> 
> I know how to put the names into one column, if I don't have all the extra
> lines.  So, I've been trying to figure out how to eliminate all lines
> except for the names.
> 
> I tried opening the file, then using a "not match" regex to eliminate all
> lines except the name lines.  So far, I can't seem to eliminate more than
> one line of "not match".   Any help will be appreciated.  Here's my feeble
> newbie code.  This code will eliminate the "Group" line, but that's it.  I
> tried adding other conditionals to eliminate other unwanted lines, but
> they don't work.
> 
> open(FH, "c:\\foobar.txt") or die "sourcefile open failed - $!";
> while (<FH>){
>             if (not $_ =~ /^Group/) {
>             print $_ ;
>             }
> }

open FH, 'c:/foobar.txt' or die "sourcefile open failed - $!";
while ( <FH> ) {
    next if 1 .. /^-+$/;
    next if /^The command completed successfully/ .. eof( FH );
    print "$_\n" for /\S+/g;
}



John
-- 
use Perl;
program
fulfillment

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