in reply to Re: Easiest way to filter a file based on user input
in thread Easiest way to filter a file based on user input
#!/usr/bin/perl use strict; use warnings; print "The lower the score the more stable the structure.", "\n", "Please set a limiting value e.g. -3: ", "\n"; my $value = <STDIN>; open IN, "file.hairpin", or die $!; my @trash; my @treasure; while (<IN>){ if ($_ =~ /^>+/){ push @treasure, $_; }elsif($_ =~ /^None+/){ push @trash, $_; }elsif($_ =~ /(^d+)/){ ## Here I don't know how to incorporate the value I get from the us +er with the value ## in the file }else{ push @treasure, $_; } } close IN; foreach my $stuff (@treasure){ open SIFTED, '>>', "new_file.hairpin", or die $!; print SIFTED, $stuff."\n"; close SIFTED; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Easiest way to filter a file based on user input
by 1nickt (Canon) on Jul 07, 2017 at 12:28 UTC | |
by Peter Keystrokes (Beadle) on Jul 07, 2017 at 14:22 UTC |