in reply to Re^9: Easiest way to filter a file based on user input
in thread Easiest way to filter a file based on user input
Oh okay, apologies for the buffoonery on my part.
The script seems to be working fine now, I added another next line: next if /^(\s\s-\d)/ && $1 > $limit;, because without it, it doesn't recognise regular Real numbers like -2, -5 etc.The script:
#!/usr/bin/perl use strict; use warnings; use Regexp::Common qw /number/; print "Enter limit: "; chomp( my $limit = <STDIN> ); #$limit = abs($limit); open my $IN, '<', "xt_spacer_results.hairpin" or die $!; open my $SIFTED, '>', "new_xt_spacer_results.hairpin" or die $!; while (<$IN>){ next if /^None/; next if /^($RE{num}{real})/ && $1 > $limit; next if /^(\s\s-\d)/ && $1 > $limit; print $SIFTED $_; } close $IN; close $SIFTED;
Haukex, you are a legend, thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Easiest way to filter a file based on user input
by haukex (Archbishop) on Jul 16, 2017 at 14:05 UTC | |
by Peter Keystrokes (Beadle) on Jul 16, 2017 at 16:23 UTC |