Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Not able to replace to directory paths
by GrandFather (Saint) on Mar 10, 2011 at 21:24 UTC | |
by Anonymous Monk on Mar 10, 2011 at 22:26 UTC | |
by Eliya (Vicar) on Mar 10, 2011 at 23:26 UTC | |
by GrandFather (Saint) on Mar 10, 2011 at 22:53 UTC | |
|
Re: Not able to replace to directory paths
by Eliya (Vicar) on Mar 10, 2011 at 21:22 UTC | |
by GrandFather (Saint) on Mar 10, 2011 at 22:40 UTC | |
|
Re: Not able to replace to directory paths
by ~~David~~ (Hermit) on Mar 10, 2011 at 21:16 UTC | |
|
Re: Not able to replace to directory paths
by Anonymous Monk on Mar 10, 2011 at 21:11 UTC |