Perolizador has asked for the wisdom of the Perl Monks concerning the following question:
#!/bin/perl $FILEIN = shift (); $FILEOUT = shift (); open(FILE, "<$FILEIN"); open(SAIDA, ">$FILEOUT"); @arquivo = <FILE>; # VETOR #@arquivo = sort(@arquivo); foreach $linha (@arquivo) { if($linha=~/(^.+<HR>Campo_Identificacao\()[^0-9]*<b>([0-9]{5,7}\-[ +^\,]*)</b>(\,.+)/) { <b>$NumProc = $2;</b> #$linhaTemp = $1."\#\$".$3; } #push @novo_array, <b>$NumProc</b> if not <b>$NumProc_anterior{ +$linha}++;</b> } print SAIDA @novo_array; close (SAIDA); close (FILE);
Hi, i would like to know how i verify multiple lines, and if the code finds that $NumProc String exists at the exact same position in the next line it would wipe out the next line, keeping only the first line found. The commented #push @novo_array line verified if the lines were exactly the same, but i want to go further and verify only if the line has the same number at the same position, hence repeated useless information.<\p>
<DI:"def.def"><RD:Item><PS:Item>Campo_Ementa ###HERE GOES THE TEXT THA +T I DONT WANT TO VERIFY[a-zA-Zetcetc]*### <HR>Campo_Identificacao(Rec +urso Inominado nº <b>0702995-42.2017.8.01.0002</b>, 1ª Turma Recursal + dos Juizados Especiais/AC, Rel. Maria Rosinete dos Reis Silva. j. 11 +.07.2018 , Publ. 20.07.<FD:AnoJulg>2018</FD:AnoJulg>).<HR><PS:Identif +icacao>
---->0702995-42.2017.8.01.0002 being the number i want to use to batch clean the document, keeping only the first time it found, completely wiping out the rest. It will be mounted into a .NFO afterwards, so i would need to keep the line intact.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array Exact Position Filter
by hippo (Archbishop) on Aug 02, 2018 at 16:06 UTC | |
|
Re: Array Exact Position Filter
by AnomalousMonk (Archbishop) on Aug 02, 2018 at 18:33 UTC | |
|
Re: Array Exact Position Filter
by Perolizador (Initiate) on Aug 02, 2018 at 22:12 UTC | |
by AnomalousMonk (Archbishop) on Aug 03, 2018 at 00:59 UTC | |
by hippo (Archbishop) on Aug 03, 2018 at 08:26 UTC |