I'm trying to read a list of URLs from a textfile and have them put into a format for easy inserting into a MySQL dbase. Only problem is after the URL I get a ^M before the "', 'General');" string.
#!/usr/bin/perl
$input = @ARGV[0];
open (INFILE, $input) || die "Unable to open @ARGV[0]!\n";
@lines = <INFILE>;
close(INFILE);
$output = ">output.txt";
open (OUTFILE, $output) || die "Unable to open output.txt!\n";
$frontfill = "INSERT INTO urls (URL, CATEGORY) VALUES ('";
$backfill = "', 'General');";
foreach (@lines)
{ chomp($lines[$x]);
print OUTFILE $frontfill;
print OUTFILE $lines[$x];
print OUTFILE $backfill;
print OUTFILE "\n";
$x++;
}
close(OUTFILE);