Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to make a small tweak

Status
Not open for further replies.

macubergeek

IS-IT--Management
Dec 29, 2004
41
US
I currently have a script that works fine.
It loads file A into an array. It then searches for each line in @A in file B.
It then reports back to me which lines in @A that id DOESN'T find in file B.
I'm printing out these results with:
print FH (@aonly, $item);
-------------------------
The Problem is, I'm getting results like
Blah Blah Blah0
or
Blah Blah Blah1
and I want to print just:
Blah Blah Blah is not in compliance
I also get:
Hi how are yaEnabled
or
Hi how are yaDisabled
and I want to print just:
Hi how are ya is not in compliance

well here's the code I'm working with thats NOT working
Code:
$item =~ s/$0//g;
$item =~ s/$1//g;
$item =~ s/$Enabled//g;
$item =~ s/$Disabled//g;
print FH (@aonly, $item) is not in compliance;
The last line is buggered. I'm getting this error:
C:\Documents and Settings\kellyji\My Documents\SCRIPTS\windows_scripts\Windows_P
erl_reg>perl file_compare.pl
Bareword found where operator expected at file_compare.pl line 76, near ") is"
(Missing operator before is?)
syntax error at file_compare.pl line 76, near ") is "
Execution of file_compare.pl aborted due to compilation errors.

I was hoping someone could point out what I've screwed up here ;-)
 
You haven't quoted the string on the last line - perl thinks 'is', 'in' and 'compliance' are supposed to be commands. Change to something like:
Code:
print FH @aonly, $item, ' is not in compliance';
 
I tried your suggestion.
It does this:
blah blah blah
blah blah blah
blah blah blah
is not in compliance

but I'm trying to do:
blah blah blah is not in compliance
blah blah blah is not in compliance
blah blah blah is not in compliance

how would I do that?
 
You'll need to read in each element of the array @aonly and print one at a time.

Code:
foreach $line (@aonly) {
    print FH $line, $item, ' is not in compliance';
}

- Rieekan
 
You may also need to chomp each element of the array
--Paul
 
Ok here's my code:
foreach $line (@aonly) {
print FH $line,$item,'WHAT SETTING SHOULD BE:';
chomp $line;
}
problem is I miss the first line I get:
yayayayayaya
What Setting Should be: yayayayaya
What Setting Should be: ababababab
What Setting Should be: xxxxxxxxxx
What Setting Should be:

 
show us a sample of your two files.



``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Put the chomp before the print statement. You may need to add a\n to your literal string; if so, you'll need to use double quotes:

Code:
foreach $line (@aonly) {
  chomp $line;
  print FH $line,$item,"WHAT SETTING SHOULD BE:\n";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top