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"

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 = $_;
	($miRID,$miR,$mirID,$mir,$scaffold,$structure,$is_mir,$start,undef) = split (/\s+/, $line);
	$table{$mirID} = $start;	
	if (undef $start)		 {
	print "$scaffold\t0\n";
	else {
	print "$mirID\t$scaffold\t$start\n";
close FILE1;


my $line = $_;
my $start='a';

This should assign a value to $start which will then be overridden if it's not undef in $line.


if ($start=='a' || undef $start) {
print "$scaffold\t0\n";
This question has already been answered. Start a new discussion instead.