You could do this from the command-line with Perl as well, but here's a small script:
Code:
#!/usr/bin/perl
use strict;
use warnings;
#$^I = '.bak';
while (<>) {
s/,.*//;
print;
}
That replaces [the comma and everything after it] with nothing. (If you want to keep the comma, use
s/,.*/,/ instead of what I have above.) Save this as, say,
edit and then run it as
perl edit file_name. If the output looks sane, then uncomment the line
#$^I = '.bak' and run it again. Once you uncomment that line, the file will actually be changed and, for no charge, Perl will make a backup as file_name.bak. That way if you did something very wrong, you have a backup. Edit - now that I think of it, can I get credit for your homework?