"Rob Dixon" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> 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.
>
> Then you still have non-graphic characters in your file records. The most
> likely is that you have a trailing <CR><LF> at the end of the lines of one
> file, and chomp() will remove only the linefeed. To fix this, use
>
>   s/\s+$// foreach @pclist;
>   s/\s+$// foreach @smsclient;
>
> instead of using chomp(). If this also fails, then try removing leading
> whitespace as well with
>
>   s/^\s+// foreach @pclist;
>   s/^\s+// foreach @smsclient;
>
> and if it's still not working, print out the invisible contents of the 
> string
> to see where they differ. An easy way is:
>
>   use URI::Escape;
>   print uri_escape($_), "\n" foreach @pclist;
>
> if you have that module installed. If it gets this far and you don't have 
> the
> module then come back here for alternatives. I have known Windows 
> utilities
> output their reports in UTF16 but I don't think net does this.
>
> Rob

Hi Rob,

Thanks  for your invaluable help. Your first option work without any glitch, 
now for my learning may is ask a
pointer for resources where could i learn the trailing of a particular line 
in a file? e.g for windows <CTRL><LF>/linux \n?
  I also tried to search by ppm the module you mention but it wasn't listed 
there.

 



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