Dear Liverpole,
First of all thanx for taking interest in this. Following is the code the way you asked. Now it is showing these errors
lobal symbol "@energy" requires explicit package name at monk.pl line 29. Type of arg 1 to push must be array (not concatenation (.) or string) at monk.pl line 29, near "})" Execution of monk.pl aborted due to compilation errors.
By the way, to rephrase my question, as 'second reply' has rightly put it, I am looking to change the array name dynamically... How this can be possible? Pl help..
#!/usr/bin/perl -w use strict; my $dinu_r; my $energy; my @energy1; my @energy2; my @energy3; my @energy4; my @energy5; my $i; for (my $x=1; $x<=5; $x++) { open (AA, "shuffle$x")or die "Can't open input ($!)\n"; # LINE A my $Sequence; $i=length($Sequence); while (<AA>) { $Sequence=$_; } close(AA); my %Winenergy = Energy($Sequence,$dinu_r); open (OUT, ">shuffle$x.stb"); # LINE B foreach my $el1(sort{$a <=> $b} keys %Winenergy) { push(@energy.$x , $Winenergy{$el1}); #LINE C # print OUT "$el1\t $Winenergy{$el1}\n"; } #print OUT "\n"; close (OUT); } sub Energy{ my ($sequence,$dinu_r) = @_; my %dinu = %$dinu_r; my $frame=1; my $win=15; my $lensequence = length($sequence); #length of the genome sequence my $limit1 = $lensequence-$win+1; #no of windows my $wincenpos = 1+($win-1)/2; #centre postion for the first window my %winenergy = (); my $j = 0; #starting position of the window while($j<$limit1) { my $winseq = substr($sequence,$j,$win); my $energy = 0; for(my $k =0; $k < $win-1; $k++) { my $dinucle_temp = substr($winseq,$k,2); my $dinucle = uc($dinucle_temp); $energy = $energy + $dinu{$dinucle}; }#end for $k my $wincentre = $j+$wincenpos; $winenergy{$wincentre} = $energy; $j = $j+$frame; }#end for $j return %winenergy; } open(FILE,">total_shuffle.stb"); my $m=8; for(my $j=0;$j<$i;$j++) { my $avg = ($energy1[$j]+$energy2[$j]+$energy3[$j]+$energy4[$j]+$energy +5[$j])/5; print FILE "$m\t$avg\n"; $m++; } close (FILE);

In reply to Re^2: Changing name of ARRAY in each iteration by cool
in thread Changing name of ARRAY in each iteration by cool

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.