Write a perl program that corrects the broken delimiting in cs371598roster.raw. Your program must print the roster with corrected delimiting–comma followed by exactly 1 space, no space before commas. You will get 2 points extra credit if you use regular expression search and replace to correct the delimiting. Include the source code of your program in perl_assignment.txt. cs371598roster.raw: Drew,Matthew J. , s1058828 Howerth, Chloe E., s1002240 Karolewicz, Michael J., s0995867 Perzely, Connor J.,s0958005 Tanenbaum, Roberto,s1124377 Williams, Gregory M., s1186794 Guan,Tiffany , s1103462 Jaligama,Vishnu Praneeth, s1143667 Jin, Ailan , s1152308 Miceli, Paul V. , s0937120 Shukla, Prerana, s1113985 Torrenegra , Harry E., s0894879 Mathighatta Shivakumar, Meghana, s1175925 Tangirala, Venkata Naga Sai Meghana, s1087887
Expert Answer
package venkanna;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class Rosterdisplay
{
public static void main(String[] args) throws IOException {
String line = null;
String[] arr2 = new String[7];
int count = 0, i = 0;
File file = new File(“D:\New folder\cs371598roster.raw”);
FileWriter fw = null;
try
{
Scanner sc = new Scanner(file);
BufferedReader br = new BufferedReader(new FileReader(file));
while (sc.hasNextLine())
{
line = sc.nextLine();
String arr[] = line.split(“[,]”);
for (String word : arr)
{
System.out.println(word);
File file1 = new File(“D:\New folder\perlAssignment.txt”);
if (!file1.exists())
{
file1.createNewFile();
}
fw = new FileWriter(file1);
fw.write(word);
}
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
}