I have followin code in one legacy script:
while (<FPTR>) # While still input lines in the file...
{
if($_ =~ /\x1b&d@
/)
{
$aa=$_;
$aa =~ s/\x1b&d@
/
\x1b&d@/;
print STDOUT $aa;
}
...
}
Could you please explain – what doe this code do and how to replace it with correct code?
I do not like that there is a line feed in “if” and “=~”.
Is it possible to change this code?
Assuming the INPUT_RECORD_SEPARATOR has not been redefined, the newline can probably be replaced by
$. Then, you should be able to chomp the copy of the input line to remove the newline. Then prepend\nto the output.This would simplify the code by eliminating multiple copies of your regex.