
BillKSmith
Veteran
Feb 11, 2013, 8:53 PM
Post #2 of 3
(187 views)
|
|
Re: [kdejan] if else equality question
[In reply to]
|
Can't Post
|
|
The operator '==' is for comparing numbers. Use the operator 'eq' to compare strings. I have several other recommendations. Always use strict and warnings. Always use the three argument form of open. Always use lexical (my) file handles. Always explicitly close all open files. Process each line of this file as a string. There is no reason to split it into a character array. Update: Added sample code (Untested due to lack of data)
use strict; use warnings; use Readonly; Readonly::Scalar my $GAP_PARTITION => 1417; Readonly::Scalar my $MAX_TITLE_SIZE => 1480; open( my $FILE, '<', "whatshappenin" ) or die $!; foreach my $line (<FILE>) { chomp $line; if ( length $line < $MAX_TITLE_SIZE ) { print $line ; next; } (my $temp = substr( $line, $GAP_PARTITION )) =~ tr /AaGg/0011/; substr($line, $GAP_PARTITION, length $temp, $temp); $line =~ s/(.)\s/$1/seg; print "$line\n"; } close $FILE; Good Luck, Bill
(This post was edited by BillKSmith on Feb 12, 2013, 7:48 AM)
|