Ok, how about this (again untested code!)

my %list;

my $listfile = 'france';
my $outfile = 'output';
my $file = '/etc/passwd';

open(OUT, ">$outfile") || die "cannot open $outfile: $!";

open(LIST, $listfile) || die "cannot open $listfile: $!";

while(<LIST>)
 {
  my $line = $_;
  chomp $line;

  $list{$line} = 1;
 }

open(FILE, $file) || die "cannot open $file: $!";

while(<FILE>)
 {
  my $line = $_;
  chomp $line;

  if($line =~ m/^(\w+):/)
     {
      my $name = $1;

      if($list{$name}){print OUT $line."\n"}
     }
 }


> The list is in a file called "france" and contains users name like:
> 
> miko
> martha
> 
> The file to control is the /etc/passwd:
> 
> miko:Sn83kdmcsd4ee:816:1005:MirceaKovari:/tmp:/bin/selfa
> nikol:Sn83kdmcsd4ee:816:1005:NiklaOlman:/tmp:/bin/selfa
> 
> I need to put in a new file the line of user
> "miko"(miko:Sn83kdmcsd4ee:816:1005:MirceaKovari:/tmp:/bin/selfa) that is
> contained in the list(file france) but not "nikol" which is not contained
> and so on for ol the list and all the /etc/passwd file.Thanks
> 
> _________________________________________________________________
> Scarica GRATUITAMENTE MSN Explorer dall'indirizzo
> http://explorer.msn.it/intl.asp.
> 
> 

Reply via email to