perl - How to match numbers that lie outside the range -


I'm trying to print range values ​​@ arr3 which are similar and the range of @ arr4 Arr4) but me The desired output is not available

File 1: Results

 As  to get the output as 1,2,8,13, please give me the following code Suggest modifications in 1..5 5 ..10 10..15  

File 2: Annotation

  3..7 9.12 14.17  < / Pre> 

code:

  #! Open / usr / bin / perl ($ inp1, "& lt; result") or die "did not get"; Open ($ INP2, "& lt; annotation") or "Not Found"; My @ arr3 = & lt; $ Inp1 & gt; My @ arr4 = & lt; $ Inp2 & gt; Forward my $ line1 (@r4) (my action 3 foreach $ 2) (mine ($ $ to $ 1, $ to1) = split (/ / .. /., $ Line1); mine (from $ 2 $, $ To2) = Partition (/;.,., $ Line2); ($ $ = $ 2 + $ 2; $ j ++) ($ $ i = $ 1 to 1; $ i ++ } {To ($ my $ j = $ 2; $ j ++) {$ res = grep (/ $ i /, @ result); To avoid repetition, if you want to save $ (! $ I! = $ J & amp; $ Res == 0) {print "$ i \ n"; push (@fluss, $ i);}}}}}}  

Try it:

  #! / Usr / bin / perl strict use; open (my $ inp1," & lt; result. Txt ") or" not found "dead; open (my $ in P2, "& lt; annotation.txt") or die "did not get"; my @root; my @ annotation; out of my $ line2 () exits to my {$ ($ 1, $ to1) = divided (/ / .. /. /, $ Line1); @ Root = (@rust, $ to 1 .. $ to1); } Print included (",", @ result), "\ n"; My% tmp_hash = Map {$ _ = & gt; 1} @ Root; My @unique = sort {$ a & lt; = & Gt; $ B} key% tmp_hash; Print included (",", @ unique), "\ n"; My @out_of_range = grep {! $ In_range {$ _}} @unique; Print included (",", @ out_of_range), "\ n";  

print descriptions are temporary, of course, to help show that what is happening when you run it is the basic idea is that you In the "result", a hash is used to eliminate duplicate numbers, and another hash to indicate which "annotation" is in.

If you do divide then I think that it will make this thing a bit easier to ignore the additional lines of input which is not a category of numbers, if your Nearly there are input files with some "extra" lines that you need to leave.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -