hi guys im quit new to perl and have some problems here
ive a csv file wich i need to sort all mathing lines go to another file ( this works), but i cant get it working that the array is counted so every element of the array gets in the math for 1 line. this is my test code where i need to add the count. @filter is my test array @ the end it will contain 60000 elements
#!/usr/bin/perl
$infile = @ARGV[0];
$outfile = "OK.txt";
$outfile2 = "ERROR.txt";
@Filter = ('01005;01000','01005;01001','01005;01002','01005;01003');
$zaehler = 0;
open(INFILE, "< $infile")
or
die "\nDatei $infile konnte nicht geoeffnet werden\n";
open(OUTFILE, "> $outfile")
or
die "\nDatei $outfile konnte nicht geoeffnet werden\n";
open(OUTFILE2, "> $outfile2")
or
die "\nDatei $outfile2 konnte nicht geoeffnet werden\n";
while (<INFILE>) { print OUTFILE if /@Filter[0]/; }
close(INFILE);
close(OUTFILE);
i tryd somthing with an foreach loop but i cant get it to work
as u see above i specived an element of the arrys and it works fine, but i need to count trough all elements ;D
UPDATE: here is a line from a file
120227714;520226667;03015;03200;0000031685;
this string 03015;03200 need to be filterd and if its ok then the hole line needs to go to a new file
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.