Perl script to check uname options

I am trying to read the /etc/security/limits.conf file to match with my specifications.

Specification should match below :

nofile=131072
noproc=131072
memlock=3500000

I have written a perl script to read the file:

#!/usr/bin/perl
$FILE1 = "/home/sriram/perl_scripts/limits.conf";
open(FILE, "$FILE1"); 
# or die("Could not open limits.conf file.");
while (<FILE>){
chomp;
foreach $word (split)
{
print "$word \n";
}
}
close(FILE);

I am not sure how to check for matching values as stated in specification.

Any help appreciated..

#!/usr/bin/perl

$LimitsFile = "/home/sriram/perl_scripts/limits.conf";

my $RefValue = {
                            nofile => 131072,
                            noproc => 131072,
                            memlock => 3500000,
                         } ;

open(FILE, '<',"$FILE1") or die("Could not open limits.conf file.");
while (<FILE>)
{
      chomp;
      foreach my $line ($_)
     {
          next if ( $_ !~ /^(nofile|noproc|memlock)=$/ ) ; 
          my($key,$val) = split(/=/,$_,2) ; 
          print "Error MESSAGE\n" if ($RefValue->{$key} != $val )  ;
     }
}
close(FILE);

I have one query though, why perl script ? i mean functionality you are looking after can be achieved easily in Bash/Ksh shell as well

It is a lot easier with awk

#! /bin/sh

awk '
NR==FNR {
        split($0, a, "=")
        var[a[1]]=a[2]
        next
}
NR!=FNR && $0!~/^#/ && NF==4 {
        if ( $3 in var && var[$3]==$4) {
                print
        }
}
' /home/sriram/perl_scripts/limits.conf /etc/security/limits.conf 

If you want perl, just run 'a2p' to convert it to perl. BTW, there is no 'noproc'. It should be 'nproc'.