joseph wrote:
>
> "Rob Dixon" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
>>joseph wrote:
>>
>>>I need help with my script, this supposedly would check a workstation
>>>listed in one file then see if it's not listed on other file, if it 's the
>>>case then append it on an output file.Basically what i got is the same
>>>unmodified list just appended on the output file. Where did i got  wrong?
>>>TIA.
>>>
>>>#!/usr/bin/perl -w
>>>
>>>use strict;
>>>use Data::Dumper;
>>>
>>>open(FL1,"pclist.txt") or die "can't open pclist.txt $!";
>>>open(FL2,"smsclient.txt") or die "can't open smsclient.txt $!";
>>>open(OUTPUT,">>unlisted.txt") or die "can't open pclist.txt $!";
>>>
>>>my @smsclient = <FL1>;
>>>my @pclist = <FL2>;
>>>my %hash = map { $_ => 1 } @pclist;
>>>
>>>foreach my $key (@smsclient) {
>>>   chomp($key);
>>>   unless(exists $hash{$key}){
>>>   print OUTPUT $key,"\n";
>>>    }
>>>  }
>>>
>>> close(FL1);
>>> close(FL2);
>>> close(OUTPUT);
>>
>>You've used the raw file records in @pclist as keys for your hash, but
>>then 'chomp'ed the data in @smsclient before you look for a match. Nothing
>>will compare as equal because one set has trailing "\n" characters while the
>>other doesn't.
>
>  Thank you for the effort, but still it didn't work, I tried to run the
> script in winXP/fedora linux platform just to make sure, still the problem
> persist.
> I really don't have any clue why this didn't work while when a try a simple
> predeclared array it did, could this be because of the format of my text
> file?
>
> For sake of clarity the format of these files are like this;
>
> smsclient.txt
>
> wkspc0001
> wkspc0002
> wkspc0003
> so..on
>
> pclist.txt
>
> wkspc0001
> wkspc0002
> wkspc0005
>
> the former is an exported list of SMS collection with the latter is produce
> by net view > out.txt.  Hoping for any feedback and suggestion, as alway
> thank you very much.

I've just checked. Windows 'net' utility doesn't output UTF16 as I suggested,
but does add trailing spaces onto each output line. Using my first option
of

  s/\s+$// foreach @smsclient;
  s/\s+$// foreach @pclist;

is likely to fix it.

HTH,

Rob

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