Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found