in reply to Re: How do I get rid of the cr/lf
in thread How do I get rid of the cr/lf
#opening the file for reading open IN,"$fileName" ; #reading the whole file into an array. my @F=<IN>; close IN; #reading the last line of the file my $lastLine=$F[$#F]; my $firstLine=$F[0]; #spliting last line by tabs my @line=split /\t/,$lastLine; #spliting first line by tabs my @firstSplitLine=split /\t/,$firstLine; #finding the column number that equals the fieldName my $fieldNum = -1; my $numberOfFields = scalar(@firstSplitLine); for($counter=0 ; $counter < $numberOfFields ; $counter++) { $ourstring = $firstSplitLine[$counter]; $ourstring =~ s/\n\n/\n/g; #=~ s/ \s//g;# HERE IS WHERE I'M TRYING + DIFFERENT STUFF... if($fieldName eq $ourstring) # The "problematic" area { $fieldNum=$counter; last; } } # if the field wasn't found if($fieldNum==-1) { print STDERR "\n" if ($permit_writing); print STDERR "The field you asked for was not found, now returning l +ast value: $lastValue\n" if ($permit_writing); print STDERR "\n" if ($permit_writing); return $lastValue; } #printing the required field print STDERR " Value: $line[$fieldNum]\n\n" if ($permit_writing); return $line[$fieldNum];
Edit: Changed <pre> tags to <code> tags (davorg)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I get rid of the cr/lf
by davorg (Chancellor) on Aug 22, 2006 at 14:08 UTC |