Extending the replies above:

re Re: Unknown numbers show up: An alternate to Athanasius' look-ahead assertion would be to insert an anchor in $replace (which would also require you to use a "quote-like" operator, qr/ ... /;)
          ...thus:  $search = qr/$temp[0],$temp[1]$/;

You might also want to read perldoc perlretut and/or perldoc perlre for a better understanding of the impact your quotes, dots, etc have on Ln 18,

   $command_line = "perl -pi\.bak -e s\/".$search."\/".$replace."\/g\; CombineDie1Die2.txt";

And, re flexvault's note: definitely, don't call another instance of Perl to execute your  s/// and especially, don't call it in a loop. Do rewrite it so the substitution is executed without system..... That's left as an exercise for the Seeker.
I'm not sure that writing to a third file is necessary, though... but that may well be merely my blindspot.

#!/usr/bin/perl use 5.010; # 1123214 #Copy Die2 as Output file use File::Copy; copy ("Die2.txt","CombineDie1Die2.txt") or die "copy failed: $!"; #Open Die1 Input file open (Label, "Die1.txt") or die "can't open Die1: $!"; #Search and replace using 1 liner command while (<Label>) { $replace = $_; chomp ($replace); @temp = split (/,/, $replace); $search = qr/$temp[0],$temp[1]$/; # using an anchor print "\t search is $search"; $command_line = "perl -pi\.bak -e s\/$search/$replace/g\; CombineD +ie1Die2.txt"; # NB the removal of numerous dots, quotes and backslashes system ($command_line); }

In reply to Re: Unknow number show up by ww
in thread Unknow number show up by Vkhaw

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.