Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can you help here please?Input File(one.txt): Alias /ans_win/ "/ans/win/" Alias /icons/ "/ans/sttp/icons/" Alias /name/ "ans/name" Mycode: open(OH,">two.txt") or die "Could not write file two.txt"; open(FH,"one.txt") or die "Could not open file one.txt"; while(<FH>){ if (($_ =~ /Alias/) && ($_ =~ /icons/)){ print"Data=> $_\n"; }else{ print OH $_; } } close OH; close FH; $out = "mv two.txt one.txt"; system($out); My Expected output file: Alias /ans_win/ "/ans/win/" Alias /name/ "ans/name"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Remove a line from a file using perl one liner
by gwadej (Chaplain) on Mar 19, 2009 at 13:54 UTC | |
Re: Remove a line from a file using perl one liner
by Bloodnok (Vicar) on Mar 19, 2009 at 13:50 UTC | |
Re: Remove a line from a file using perl one liner
by smanicka (Scribe) on Mar 19, 2009 at 14:05 UTC | |
Re: Remove a line from a file using perl one liner
by olus (Curate) on Mar 19, 2009 at 13:56 UTC | |
by ikegami (Patriarch) on Mar 19, 2009 at 14:00 UTC | |
by olus (Curate) on Mar 19, 2009 at 14:09 UTC | |
by Anonymous Monk on Mar 19, 2009 at 14:11 UTC |