Hi,
I wrote this script to help me cleanup some data. The value in the 8th column is sometimes empty. When it is empty, I want it to print a zero as in the next part of the script it will be adding a number to whatever is in that column. The script doesn't trigger any errors other than: Use of uninitialized value $start in concatenation (.) or string at lineXXX. Thanks in advance!
Sample data:
23 "ugguuucacgugauacguauu" 22 "ccaugcacuacgcaccaugcacugugcacccuuguaaagugcacuuccauuaugcauagugcacuuugguguggugcgugu" 18 1 "is_MIRNA" 51
23 "ugcacugugcacccuuguaaa" 23 "agaggcauaacgagaggaaccuucgcacacaaacggcacuuaaguugucgggauaacuucacaguuauuucggcgaucauguguuuggcgccguugccggggacaucucucguugcuucg" 18 0 "is_MIRNA"
#!/usr/bin/perl
use warnings;
use strict;
open (FILE1, $ARGV[0]) or die "Can't open file1\n";
my %table;
my ($miRID,$miR,$mirID,$mir,$scaffold,$structure,$is_mir,$start);
foreach (<FILE1>){
my $line = $_;
chomp;
($miRID,$miR,$mirID,$mir,$scaffold,$structure,$is_mir,$start,undef) = split (/\s+/, $line);
chomp;{
$table{$mirID} = $start;
if (undef $start) {
print "$scaffold\t0\n";
}
else {
print "$mirID\t$scaffold\t$start\n";
}
}
}
close FILE1;
exit;