in reply to using Getopt::Long

What part of modifying your script do you have the problem with? Is it with adding the functionality of the unique feature? This would be solvable by reading perlfaq4 on "unique". Or is your problem with the usage of GetOpt::Long? Then it's as easy as the following:

GetOptions( 'u|unique' => \my $unique, );

Replies are listed 'Best First'.
Re^2: using Getopt::Long
by v15 (Sexton) on Sep 27, 2016 at 19:47 UTC
    How would the full code look like?
    #!/usr/bin/perl-w use strict; use warnings; use Data::Dumper; use Getopt::Long; my $unique; GetOptions( 'u|unique' => \my $unique, ); while(<>){ chomp; my @s = split /\t/,$_; my $count = $s[6]; if($count > 10){ print $_,"\n"; } }
    $unique somehow should replace $count in the loop right??

      It helps us help you better if you are more explicit about where exactly you encounter problems.

      What part of perlfaq4 is problematic for you? I think especially the section on How can I remove duplicate elements from a list or array applies to your problem.

      Maybe you can adapt the code and approach presented there and get back to us when you encounter concrete problems. Please take the time to describe the problem you encounter, together with the input you give, the output you get and the output you expect.

      Did you try it? Would trying it take longer than typing a reply to ask a question, then waiting for answers, then trying it anyway? You're using Perl right? You are supposed to be lazy. Lazy is doing the least work. In this case trying it yourself is the least work by far.

      Premature optimization is the root of all job security
        GetOptions( 'u|unique' => \my $unique, ); open F,'/Users/gupta567varun/Desktop/AAC_SJ.out.tab',or die $!; while(<F>){ chomp; my @s = split /\t/,$_; my $count = $s[6]; if($count > $unique){ print $_,"\n"; } } close F;
        Thanks for pointing me out the documentation. What is wrong here in the code. I ran it like this perl script.pl -u 4 , but it still prints lines less than 4?? EDIT:
        #!/usr/bin/perl-w use strict; use warnings; use Getopt::Long; GetOptions( 'uniq=i' => \my $unique, ); while(<>){ chomp; my @s = split /\t/,$_; my $count = $s[6]; if($count > $unique){ print $_,"\n"; } }
        Running the script as

        perl script.pl --uniq 4 file.txt

        Works now!! Thanks