----- Original Message -----
From: "William Martell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 22, 2003 11:19 AM
Subject: Re: Newbie trying to cleanup/format text file


> Hi Stuart,
>
> This is as far as I could take it:  Any critiques or suggestions on my
code
> would be welcome and appreciated.
>
> #!/perl
>
> open(INFILE, "stuart_clemens_ibm.txt") || die "Could not open file";
>
>
> @data;  #declare array for later use
>
> while ( $line = <INFILE> ){
>
> #get rid of all other lines
> $a = "Group name";
> $b = "Misc";
> $c = "Comment";
> $d = "These are the FOOBAR users";
> $e = "Members";
> $f =
>
"---------------------------------------------------------------------------
> ----";
> $g = "The command completed successfully.";
>
>
> # get rid of group name
> $line =~ s/$a//;
>
> # get rid of Comment
> $line =~ s/$b//;
>
> # get rid of Misc
> $line =~ s/$c//;
>
> # get rid of "These are the foobar users
> $line =~ s/$d//;
>
> # get rid of Members
> $line =~ s/$e//;
>
> # get rid of dashes
> $line =~ s/$f//;
>
> # get rid of command completed
> $line =~ s/$g//;
>
> # get rid of blank lines
> #$line =~ s/^\n//;
>
> # get the member names from each column
> $col1 = substr($line, 0,24);
> $col2 = substr($line, 25,24);
> $col3 = substr($line, 50,24);
>
> # push the names onto an array
> push @data, $col1;
> push @data, $col2;
> push @data, $col3;
>
>
>  }
>
>
> # print the array
> print @data;
>
>
>
>
>
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, December 22, 2003 10:16 AM
> Subject: Newbie trying to cleanup/format text file
>
>
> > Hi all:
> >
> > 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 $_ ;
> >             }
> > }
>

Attachment: stuart_clemens_ibm.pl
Description: Perl program

Group name      Misc
Comment        These are the FOOBAR users

Members

-------------------------------------------------------------------------------
arod                     cschilling               csenior 
ecostello                ffrank                   gbennett 
LBird                    PMartinez 
The command completed successfully.


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