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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |