What i am trying to accomplish is if the model is set to "N\A" and the kernel variable has xen somewhere in it i would like to change the variable to "virtual machine". Otherwise just leave it alone. The rest of my script works great this is the last part. The code above does not do what i want it to, it turns every model into a virtual machine regardless if it is set or not.
$
$
$ cat insania.pl
#!/usr/bin/perl -w
$model = $ARGV[0];
$kernel = $ARGV[1];
print "Before if...\n";
print "model = $model\n";
print "kernel = $kernel\n";
# if the model is set to "N\A" and the kernel variable
# has xen somewhere in it i would like to change the
# variable to "virtual machine".
# Otherwise just leave it alone.
if ($model eq "N\\A" and $kernel =~ m/xen/) {
$model = "Virtual Machine";
}
print "\nAfter if...\n";
print "model = $model\n";
print "kernel = $kernel\n";
$
$ # Case 1 : model is "N\A" and kernel has "xen" in it
$
$ perl insania.pl "N\A" abcxenabc
Before if...
model = N\A
kernel = abcxenabc
After if...
model = Virtual Machine
kernel = abcxenabc
$
$
$ # Case 2 : model is "N\A" and kernel does not have "xen" in it
$
$ perl insania.pl "N\A" abcyenabc
Before if...
model = N\A
kernel = abcyenabc
After if...
model = N\A
kernel = abcyenabc
$
$
$ # Case 3 : model is not "N\A" and kernel has "xen" in it
$
$ perl insania.pl "M\A" abcxenabc
Before if...
model = M\A
kernel = abcxenabc
After if...
model = M\A
kernel = abcxenabc
$
$
$ # Case 4 : model is not "N\A" and kernel does not have "xen" in it
$
$ perl insania.pl "M\A" abcyenabc
Before if...
model = M\A
kernel = abcyenabc
After if...
model = M\A
kernel = abcyenabc
$
$