Have you run it? If not, do so. It is self contained and you can see the input data and fairly quickly infer what the result of running the program is.
Personally I'd be inclined to refactor the code a little to remove some of the magic and make to workings a little clearer. Consider:
#!usr/bin/perl use strict; use warnings; use Data::Dumper; my @data = qw(AAA ATG TTT GTC); my %hash; for my $entry (@data) { my @codes = split //, $entry; ++$hash{$codes[$_]}[$_] for 0 .. $#codes; } print Dumper (\%hash); foreach my $entry (values %hash) { $entry = [map {defined $_ ? $_ : 0} @$entry]; } print Dumper (\%hash);
Note that I've removed the unused variables, renamed @deep to @codes to better express its use, made @codes local to the loop and got rid of the interesting (but unusual) glob construction, and moved the split inside the loop rather than using the slightly more magical construct with the map. I also changed from using a post increment to a pre-increment so the operator is more visible.
I also added a dump before the second loop so the effect of that loop is obvious. If you are still having trouble with the code and what it is doing I suggest you run it and try changing the input data to see what the effect is, then look carefully at the code to see how it is doing its trick.
In reply to Re: can this perl script be explained how and what it is going on...????
by GrandFather
in thread can this perl script be explained how and what it is going on...????
by sharanyaravi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |