I have a text file whose data looks like the following,Now I am trying to do the following,currently my code is not working for step2.

For every line starting with "missing" on the input file below 1.replace "\" with "/" 2.replace $root_dir with $perforce_root_dir 3.Save the resulting perforce path in another text file "perforcefiles.txt"

INPUT FILE(p4diff.log) DATA:- missing E:\qdepot_automation\addfiles.txt same E:\qdepot_automation\AMSS\products\build\ms\files.data same E:\qdepot_automation\AMSS\products\build\ms\build.cmd missing E:\qdepot_automation\AMSS\products\build\textfiles.txt same E:\qdepot_automation\AMSS\products\build\ms\lib.min #!/usr/bin/perl -w use strict; use warnings; use Cwd; my $client_root="E:\\qdepot_automation"; my $perforce_root_dir="\/\/depot\/code"; my $input = <p4diff.log>; my $line; #my ($client_root,$clientroot); open(my $OUTPUT, '+>', "perforcefiles.txt") or die $!; open my $DATA, '<', $input or die "could not open '$input' $!"; while ($line = <$DATA>) { if ($line =~ /missing/) { $line =~s/\\/\//g; $line =~s/$client_root/$perforce_root_dir/g; ###This line is not wo +rking,basically am not able to replace client_root with perforce_root +_dir print "$line\n"; print $OUTPUT $line; } } close OUTPUT; OUTPUT:- E:\qdepot_automation>perl deletefiles.pl Name "main::OUTPUT" used only once: possible typo at deletefiles.pl li +ne 25. missing E:/qdepot_automation/addfiles.txt

In reply to Not able to replace to directory paths 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.