I was trying to understand your code and I just got lost!
Can you provide just 2 input files and desired output?

Here is where I got to before being completely lost.

#!/usr/bin/perl use strict; # turned on strict and warnings. use warnings; # a "#" in front makes them comments my $DFile="/home/infosec/data/RegEx"; open (DATAF, "<$DFile") || die ("Cannot open DATAF file \n"); # don't use DATA as a file handle, that is a reserved word for Perl. # no need to "eval" $regex foreach my $line (<DATAF>) { chomp $line; my ($tname, tvalu, $tfile, $regex) = split(/:/, $line); open (TFILE, "<$tname") || die ("Cannot open Test file $tname\n"); while (<TFILE>) { next unless /$regex/; print $_; # this is so obtuse that my brain hurts! # These super tricky Perl Special Variables like # $& $- $+ are EXTREMELY seldom needed. Get rid of them. # please explain what this is supposed to do.... # $- is a scalar, not an array, what do you intend by $-[0]? # # print "\t\t\$&: ", # substr( $_, $-[0], $+[0] - $-[0] ), # "\n"; # foreach my $i ( 1 .. $#- ) # { # print "\t\t\$$i: ", # substr( $_, $-[$i], $+[$i] - $-[$i] ), # "\n"; # } } print "\n"; } print "\n";

In reply to Re: Test RegEx by Marshall
in thread Test RegEx by Saved

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.