For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > November 2005 > can i do in Perl too ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author can i do in Perl too ?
Rita

2005-11-17, 6:56 pm

Hi Members,
I have little bit knowleadge about C but i am new in Perl.
i want to store value like
i have some value
$start1=34;
$end 1=50;
$start2=56;
$end2=100;
..
..
..
..
$start10=200;
$end10=250;
so all time i don't want to use a new variable.
i remember in C we can use for loop for (i=1;i=10;i++);
and then start[i]=
end[i]=
but how i can use this logic in Perl?
thanks

usenet@DavidFilmer.com

2005-11-17, 6:56 pm

Rita wrote:
> i have some value
> $start1=34;
> $end 1=50;
> $start2=56;
> $end2=100;
> so all time i don't want to use a new variable.
> i remember in C we can use for loop for (i=1;i=10;i++);
> and then start[i]=
> end[i]=
> but how i can use this logic in Perl?


You can use the same loop syntax in Perl (though Perl makes it easier
for a simple iteration like this; you can do "for (1..10)" instead.
But this won't accomplish what you think (in either C or in Perl).

you could do this:
my @start = qw/34 56 ...... 200/;
my @end = qw/50 100 ...... 250/;

and now $start[1] == 56 and $end[1] == 100 (array indexes begin at
zero, just like C).

Rita

2005-11-18, 6:57 pm

yes but it is running in loop .and
if my $start[0]=34 and end[0]=50 is this time and it goes in loop then
now again it change the value of start[0]=56
and end[0]=100.
but i want this all value sepratly.
then i can use formulas like,
subseq(start[1]+1,end[0]-1);
you know what i mean?
thanks

pokerlad@gmail.com

2005-11-18, 6:57 pm

Does this help?

my (@start,@end);


my $s=56;
my $e=7;
unshift(@start,$s);
unshift(@end,$e);

$s=32;
$e=25;
unshift(@start,$s);
unshift(@end,$e);

print "$start[0],$start[1]\n";
print "$end[0],$end[1]\n";


Rita wrote:
> yes but it is running in loop .and
> if my $start[0]=34 and end[0]=50 is this time and it goes in loop then
> now again it change the value of start[0]=56
> and end[0]=100.
> but i want this all value sepratly.
> then i can use formulas like,
> subseq(start[1]+1,end[0]-1);
> you know what i mean?
> thanks


Rita

2005-11-18, 6:57 pm


pokerlad@gmail.com wrote:
> Does this help?
>
> my (@start,@end);
>
>
> my $s=56;
> my $e=7;
> unshift(@start,$s);
> unshift(@end,$e);
>
> $s=32;
> $e=25;
> unshift(@start,$s);
> unshift(@end,$e);
>
> print "$start[0],$start[1]\n";
> print "$end[0],$end[1]\n";
>

Here is my code i want to do this work
my $result=$in->next_result;
my $hit =$result->next_hit;
my $hsp1 =$hit->next_hsp;
my$start1=$hsp1->query->start;
my $end1=$hsp1->query->end;
print "start First Hsp ",$start1,"\n";
print "End First Hsp ",$end1,"\n\n";

#Print Starting and Ending Point of 2 Hsps-
my $hsp2 =$hit->next_hsp;
my$start2=$hsp2->query->start;
my $end2=$hsp2->query->end;
print "start Second Hsp ",$start2,"\n";
print "End Second Hsp ",$end2,"\n\n";

#Print Get Sequence
print "Gap Sequence- ",$seq1->subseq($end1+1,$start2-1);
you can see that i did same work twice bcoz of to get value of $end1
and $start2
how i can put in loopthis thing.i tried while loop but it's not working
..
thanks

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com