Perl: the Markov chain saw | |
PerlMonks |
Re: read files into 2D arrays and print element?by haukex (Archbishop) |
on Nov 29, 2016 at 17:08 UTC ( [id://1176833]=note: print w/replies, xml ) | Need Help?? |
Hi fasoli, BrowserUk and LanX already gave you some solutions, I just had a few other suggestions for your code: Note that you write /${molec}-times-(\d+)-clust(\d{1})/;, but then you don't check whether the match succeeded (e.g. /.../ or die "Didn't match filename $_";), if it didn't then the variables $1, $2 etc. won't be updated! Try printing out the filename "$path\/${molec}-times-${times}-clust${cluster}.out" to ensure that you're generating the correct filename (probably easiest to store the filename in a variable first). A few more: use glob instead of `ls ...`, and only declare your variables in the scope where they're actually needed, otherwise they're hardly any better than globals (open my $input, ..., while (my $line = <$input>), etc.). Hope this helps,
In Section
Seekers of Perl Wisdom
|
|