As borisz says it should work. Add a sanity check to ensure it really contains what you expect like this (note the quotes around the value let you see hidden spaces/newlines which may be the issue)
warn "Value of \$hashnew{\$com}: '$hashnew{$com}'\n"; while(<FILE1>) { print WFILE $_ if m/$hashnew{$com}/; }
A while loop is a more usual way to iterate over a files content and more efficient that your foreach. Newlines remain attached so you don't need to add one when you print the file out (unless you are using -l switch)
On unix you could get the same functionality of this snippet with something like grep context file1 > wfile
cheers
tachyon
In reply to Re: File parsing
by tachyon
in thread File parsing
by sashac88
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |