[EMAIL PROTECTED] wrote:

> I kept working at it and was finally able to get rid of the unwanted lines
> in the text file using a series of nested if's.  It's certainly not
> elegant, but it works !
>
> Surely there's a more efficient way to get rid of the unwanted lines.

Definitely!

>
>
>  Anyway, here's what I came up with for now.  This leaves the names in
> one, two, or three columns, but I know how to reformat them into one name
> per column.
>
> #!/usr/bin/perl -w
> use strict;
> $_ = "";
> open(INFILE, "c:\\foobar.txt")or die "sourcefile open failed - $!";
>
> while (<INFILE>){
>      if (not $_ =~ /^The request/){
>       if (not $_ =~ /^Group/){
>        if (not $_ =~ /^Comment/){
>         if (not $_ =~ /^Members/){
>          if (not $_ =~ /^------/){
>           if (not $_ =~ /^The command/){
>            if ($_ =~ /\S/){
>             print $_ ;
>            }
>           }
>          }
>         }
>        }
>       }
>      }
> }
> close

Greetings! E:\d_drive\perlStuff>perl -w -Mstrict
while (<DATA>) {
   last if /^\-\-\-\-\-/;   #should be enough to identify the line;
}

my @just_usernames;
while (<DATA>) {
   last if /^The command/;
   chomp;
   s/^\s+//;
   s/\s+$//;
   my @tokens = split /\s+/, $_;
   push @just_usernames, "$_\n" foreach @tokens;
}
print for @just_usernames;

__DATA__
Group name      Misc
Comment        These are the FOOBAR users

Members

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


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