You need a function that compares two strings and returns "TRUE" if they are sufficiently similar and "FALSE" otherwise. In general, this is impossible. We must settle for a function that is good enough. We determine "good enough" by testing. Only you can determine how much testing is required. I doubt that your example of one match and several mismatches is sufficient. Here is a sample of test code using a match and a mismatch from your test cases. I have provided my first attempt (special_match) at you function to get you started.
use strict; use warnings; use Test::More tests=>2; my $should_match = 1; my $should_not_match = 0; my @cases = ( ['ON_DIE_FILLER/filler_fuse', 'die0_ON_DIE_FILLER_ON_DIE_FILLER_filler_fuse', $should_match, ], ['ON_DIE_FILLER/filler_fuse', 'die0_ON_DIE_FILLER_ON_DIE_FILLER_filler_byte', $should_not_match, ], ); foreach my $case (@cases) { if ($case->[2] == $should_match) { ok( special_match($case->[0], $case->[1]), $case->[1]); } else { ok( !special_match($case->[0], $case->[1]), $case->[1]); } } sub special_match { my ($s1,$s2) = @_; $s1 =~ tr{/}{_}; # fix separator return $s2 =~ m/$s1$/; # $s1 at end of $s2 } OUTPUT: 1..2 ok 1 - die0_ON_DIE_FILLER_ON_DIE_FILLER_filler_fuse ok 2 - die0_ON_DIE_FILLER_ON_DIE_FILLER_filler_byte
Bill

In reply to Re: Text file manipulation by BillKSmith
in thread Text file manipulation by Sajn_00

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.