Hello,
I am trying to modify a small script I found online.
It's a great script that test for and then removes duplicates. The issue is I have to manually edit the script to point to the file needing dupes removed. So what I want to do is add some keyboard / <STDIN> interaction.
I want to prompt for the file location and maybe even the output loaction and filename. I have added the print statment (which works) but the rest of the script dies once I enter the file location
Here is the script:
==========================================
=========================================
I am trying to modify a small script I found online.
It's a great script that test for and then removes duplicates. The issue is I have to manually edit the script to point to the file needing dupes removed. So what I want to do is add some keyboard / <STDIN> interaction.
I want to prompt for the file location and maybe even the output loaction and filename. I have added the print statment (which works) but the rest of the script dies once I enter the file location
Here is the script:
==========================================
Code:
#!/usr/bin/perl
print "Type in the location of the file you what to remove duplicates: \n";
$file = <STDIN>;
my %seen = ();
{
local @ARGV = ($file);
local $^I = '.bak';
while(<>){
$seen{$_}++;
next if $seen{$_} > 1;
print;
}
}
print "finished processing file\n";