I am not sure what you are trying, but a few comments.
You declare my $empNUM; but later refer to $empNum - Possible Type ??
since you are using my try to be consistant.. so you line foreach $line (@line) would look like foreach my $line (@line)
instead of exiting I.e. exit 0; you might have employees to process after you found a match so instead do a next
So you might end up with something like
my $empNUM;
open(DATA, "data") or die ;
open(UPDAT, ">updated") or die;
while(<DATA>)
{
my @line = split(/\s+/, $_); #Assuming your file is split on multi
+ple spaces..?
if ($line[2] eq $empNUM){
next;
}
else {
print UPDAT "$_";
}
}
close(DATA);
close(UPDAT);
Update: Removed the foreach as it is not necessary..
-----
Of all the things I've lost in my life, its my mind I miss the most.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|