Hi folks, I'm writing a little applet to archive call data records. I need to process many files and filter their contents before placing the desired data into an archive file. I've created an array and imported the file contents and used "foreach" to loop through the "line" printing it to an output file. I'd like to "filter" the contents in the print statement but can't get it to work. My code looks like this:
#!c:/perl/bin/perl.exe -w use strict; use diagnostics; open OUTPUT,"<","c:\/Perl\/Project\/Files\/SMDR.log.prs.20090220_08423 +0.prd" or die "Couldn't open smdr file; $!\n"; my @lines = <OUTPUT>; #loop through the array values and print each foreach my $lines (@lines) { open (OUTFILE, ">>c:\/perl\/project\/archive.txt"); print OUTFILE "$lines"; #here's where I'd like to filter out any lines + containing "/" a slash character close OUTFILE; }
I confess I'm somewhat new to perl but I've searched for days now for an example that works and have had no luck. Perhaps I'm going about it the wrong way. I'd appreciate any comments. Regards, Generator

In reply to Print while filtering ouput... by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.