in reply to Re: using Getopt::Long
in thread using Getopt::Long

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??

Replies are listed 'Best First'.
Re^3: using Getopt::Long
by Corion (Patriarch) on Sep 27, 2016 at 19:54 UTC

    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.

Re^3: using Getopt::Long
by GrandFather (Saint) on Sep 27, 2016 at 19:55 UTC

    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