Hi William,
On Tuesday 15 Feb 2011, William Muriithi wrote:
> Pal,
>
[snip]
> I am trying to list files that exist on file1 that are missing on file2 and
> have the following script:
>
> #! /usr/bin/perl
>
> use strict;
> #use warning;
>
> open MSRT, "/Users/williamm/Documents/file1" or die $!;
> open Test_server, "/Users/williamm/Documents/file2" or die $1;
> #open MSRT, "/Users/williamm/test1_rpm.txt" or die $1;
> #open Test_server, "/Users/williamm/test2_rpm.txt" or die $1;
>
> my $tom;
> my $msrt;
>
> while ($tom = <Test_server>) {
> chomp($tom);
> # print "T:$tom\n";
> while ($msrt = <MSRT>) {
> chomp($msrt);
> # print "M:$msrt\n";
> if ($msrt =~ /^\Q$tom\E/){
> # if ($msrt =~ m/^$tom.*$/){
> print "$tom: $msrt\n";
> # print "Found\n";
> }
> }
> }
>
>
#read MSRT first
@msrt = <MSRT>;
chomp(@msrt);
#perform the check while reading Test_server
while ($tom = <Test_server>)
{
chomp($tom);
my @result = grep { /\Q$tom\E/ } @msrt;
print "$tom: @result\n" if @result;
}
#That's it!
> Thanks in advance
>
> William
HTH :-)
--
Regards,
Akhthar Parvez K
http://www.sysadminguide.com/
UNIX is basically a simple operating system, but you have to be a genius to
understand the simplicity - Dennis Ritchie
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/