Quoting Roman <[EMAIL PROTECTED]>:

Hope fully this helps

### Script start

use strict;

my $process_dir =
'C:\work\_RHWork\projects\perl-beginers\directory-read\files-dir';

opendir(DIR,$process_dir) or die "Can't open dir: $! \n";
    my @files = readdir(DIR)  or die "Can't read dir: $! \n";
closedir(DIR);

my %macPCName;

foreach my $file (@files)
{
      next if ($file eq ".");
      next if ($file eq "..");
      #print "File: ", $file ." \n";

      my @pcDetails = split/,/, $file;

      # Get the PC and the mac adderess if we can..
      if($pcDetails[0] =~ /^pc=(.+)/i)
      {
          my $pcName = $1;

          open(IN, $process_dir .'\\'. $file) or die "Can't open file: $file
: error $1 \n";
          while(my $line =<IN>)
          {
              if($line =~ /Mac-Adresse:\s+(.+)/i)
              {
                  #print "Mac address: [[[" . $1 . "]]] \n";
                  $macPCName{$1} = $pcName;
              }
          }
          close(IN);

          #print "pcdetails: $pcDetails[0] : pc name : ", $1 ."\n";
      }
}

while ( my ($key, $value) = each %macPCName) {
      # print out the pc name and mac address
        print "$value $key\n";
 }

print "Done !!!!! \n";

exit(0);
#### Script end


Cheers
Roman

Hello  Roman,

I get an error

File: PC=atlantis1,USER=rehastatpflege,OS=W2K-XP.txt
Can't open file: PC=atlantis1,USER=rehastatpflege,OS=W2K-XP.txt
: error atlantis1

Does perl try to open atlantis1 instead of the full name ?

Bye
Andreas




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to