in reply to Re^2: Easiest way to filter a file based on user input
in thread Easiest way to filter a file based on user input
Hi, thanks for posting your code.
Here is a version that appears to do what you want. Note the following things:
#!/usr/bin/perl use strict; use warnings; use feature 'say'; print "The lower the score the more stable the structure.", "\n", "Please set a limiting value e.g. -3: ", "\n"; chomp( my $value = <STDIN> ); chomp( my @input = <DATA> ); my @trash; my @treasure; for ( @input ){ if ( /^>+/ ) { say "$_ matches '/^>+/'"; push @treasure, $_; } elsif ( /^None/ ) { say "$_ matches '/^None/'"; push @trash, $_; } elsif( /(^[\d\.-]{4})/ ) { say "$_ matches '/(^[\d\.-]{4})/'"; if ( $1 <= $value ) { say "$1 is <= $value"; push @treasure, $_; } else { say "$1 is > $value"; push @trash, $_; } } else { say "$_ doesn't match anything!"; push @trash, $_; } } say 'Treasure:'; foreach my $stuff ( @treasure ) { say $stuff; } __END__ hsa_circ_0067224|chr3:128345575-128345675-|NM_002950|RPN1 FORWARD -4.4.. 6 .. 17 xxxxxxxxxxGTGAC CAGT ATGC ACTG AAGATGAGGTTTGTG -0.9.. 5 .. 18 xxxxxxxxxxxGTGA CCAGT ATGC ACTGA AGATGAGGTTTGTGG None.. 1 .. 20 xxxxxxxxxxxxxxx GTGACCAGTATGCACTGAAG ATGAGGTTTGTGGAC
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Easiest way to filter a file based on user input
by Peter Keystrokes (Beadle) on Jul 07, 2017 at 14:22 UTC |