Amit
asked on
Old perl code not working on Mac
I had this question after viewing Help with parsing two files.
The old solution has stopped working on mac.
this is the output of perl -v
This is perl 5, version 28, subversion 0 (v5.28.0) built for darwin-2level
(with 1 registered patch, see perl -V for more detail)
ASKER
open F2,");
close F2;
while( ){
s/\$name/shift @name/eg;
print;
}
ASKER
ASKER
The same code used to work on windows but on Mac something is wrong
ASKER
You can also rewrite the code : this is the purpose of code
Hi,
I have two files
file1 and file2
file1 contains
----------------------------------------------------------------------------------------
else if (Headers[i].indexOf(strAverepQueueTime)!= -1)
{
$name = i;
}
else if (Headers[i].indexOf(strExecutingreps)!= -1)
{
$name = i;
}
else if (Headers[i].indexOf(strrepsCompRate)!= -1)
{
$name = i;
}
else if (Headers[i].indexOf(strtotCompletedreps)!= -1)
{
$name = i;
}
............................................
............................................
............................................
file2 contains
--------------------------------------------------
AverepQueueTimeindex
Executingrepsindex
repsCompRateindex
totCompletedrepsindex
............................................
............................................
............................................
so what I need to do is replace each $name in file1 by consecutive string in file2
so the final output should look like
else if (Headers[i].indexOf(strAverepQueueTime)!= -1)
{
AverepQueueTimeindex = i;
}
else if (Headers[i].indexOf(strExecutingreps)!= -1)
{
Executingrepsindex = i;
}
else if (Headers[i].indexOf(strrepsCompRate)!= -1)
{
repsCompRateindex= i;
}
else if (Headers[i].indexOf(strtotCompletedreps)!= -1)
{
totCompletedrepsindex= i;
}
Hope this helps. Please let me know if there are any further questions.
Hi,
I have two files
file1 and file2
file1 contains
----------------------------------------------------------------------------------------
else if (Headers[i].indexOf(strAverepQueueTime)!= -1)
{
$name = i;
}
else if (Headers[i].indexOf(strExecutingreps)!= -1)
{
$name = i;
}
else if (Headers[i].indexOf(strrepsCompRate)!= -1)
{
$name = i;
}
else if (Headers[i].indexOf(strtotCompletedreps)!= -1)
{
$name = i;
}
............................................
............................................
............................................
file2 contains
--------------------------------------------------
AverepQueueTimeindex
Executingrepsindex
repsCompRateindex
totCompletedrepsindex
............................................
............................................
............................................
so what I need to do is replace each $name in file1 by consecutive string in file2
so the final output should look like
else if (Headers[i].indexOf(strAverepQueueTime)!= -1)
{
AverepQueueTimeindex = i;
}
else if (Headers[i].indexOf(strExecutingreps)!= -1)
{
Executingrepsindex = i;
}
else if (Headers[i].indexOf(strrepsCompRate)!= -1)
{
repsCompRateindex= i;
}
else if (Headers[i].indexOf(strtotCompletedreps)!= -1)
{
totCompletedrepsindex= i;
}
Hope this helps. Please let me know if there are any further questions.
How did you transfer the file from Windows to unix?
Try cat -V replacer.pl
Do you see ^M in the output?
dos2unix shoukd strip the extraneous character.and fix your issue
Try cat -V replacer.pl
Do you see ^M in the output?
dos2unix shoukd strip the extraneous character.and fix your issue
ASKER
Hi Arnold,
Would you be able to rewrite the script for me based on what you see in the code. I had pasted the code from experts-exch to vi editor and that's it ?
cat -v is not showing me anything
So the best help would be if experts like you could rewrite the code for the problem statement that I have shared
Would you be able to rewrite the script for me based on what you see in the code. I had pasted the code from experts-exch to vi editor and that's it ?
cat -v is not showing me anything
So the best help would be if experts like you could rewrite the code for the problem statement that I have shared
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The error points to a double quote mismatch
Sone where prior to line 3
The sample was four replacements. How many lines in file2?