It is important to use copy and paste to post your code otherwise we end up chasing transcription errors. In this case while(<fhand>}{ is bad syntax and is probably a transcription error. But what about if($First = 1); (assign 1 to $first - the test is always true)? Transcription error or bug?
You should always add use strict; use warnings; to your code. They will catch many silly mistakes. In this case both the errors pointed out above would have been caught.
Of less importance in ($_ =~/ the $_ =~ is redundant.
You don't actually provide any test data and you don't say under what circumstances the result is incorrect. The followign code should serve as a starting point for elaborating on the actual problem you are having:
use strict; use warnings; while (<DATA>) { next if (m/First Name/ .. m/Last Name/); next if ! m/Last Name/; print "Order is not correct\n"; last; } __DATA__ ....... Last Name ...... ....... First Name .......
Prints:
Order is not correct
In reply to Re: File reading
by GrandFather
in thread File reading
by qsl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |