in reply to read files into 2D arrays and print element?
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,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: read files into 2D arrays and print element?
by fasoli (Beadle) on Nov 29, 2016 at 17:15 UTC |