apple.c pears.c watermelons.ci want to delete these files using some code in perl -ne however if my file contains stuff like
apple.c Errors Errors pears.c Errors Errors Errors watermelon.ci want the perl command line to delete only the watermelon.c file since it has no Errors statements following the file name in the list I hope I made this clear
If I read you right ...
perl -nle '$_ eq "Errors" ? pop(@f) : push(@f, $_); END {unlink @f}'
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
Oh sorry, I forgot to indicated that there could be multiple Errors statements
Oh well. Slight modification:
perl -nle '$_ eq "Errors" ? delete($f{$prev}) : $f{$prev=$_}++; END {unlink keys %f}'
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
perl -lne '/\.c$/?$h{$l=$_}++:delete$h{$l}}{unlink keys%h' file.txt
perl -0ne 'unlink /.+\n(?:Errors$)+|(.+)/mg'
perlmonks.org content © perlmonks.org and delirium, EchoAngel, muba, Neutron Jack, Sidhekin
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03