I am writing a script that will take a file and add a '/' at the end of the line if the line begins with '16' and it currently doesn't have a '/' at the end. I can get it to find the lines that start with 16, but it adds a second '/' even if the line already ends in one. I am writing this on a Windows 2000 pc. Here is what I have so far:
My input file is currently like this:
and I would need the file to look like this:
Any suggestions would be greatly appreciated.
Thanks.
Code:
open(BANK, "<Wac 5-3-04.wcr") or die "Can't open bank input.\n";
@B = <BANK>;
while($Bank = shift(@B))
{chomp ($Bank);
{if (($Bank =~m/^16/) && ($Bank !=~m/\/$/)){
print "$Bank/\n";
}
else
{print "$Bank\n";
}
}
}
My input file is currently like this:
Code:
16,475,19504,Z,118,78,CHECK
16,575,1207,Z,0000,,TRANSFER TO LA MAD OF
16,255,58,S,58,000,000,118,,CHECK REVERSAL
16,275,855,S,855,000,000,00,/
88,TRANSFER FROM LA MAD OF
and I would need the file to look like this:
Code:
16,475,194,Z,1500,78,CHECK/
16,575,127,Z,0000,,TRANSFER TO LA MAD OF/
16,255,580,S,580,000,000,118,,CHECK REVERSAL/
16,275,85,S,85,000,000,000,/
88,TRANSFER FROM LA MAD OF
Any suggestions would be greatly appreciated.
Thanks.