For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Simple Doubt









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 Simple Doubt
nikne

2006-10-09, 7:59 am

This is my script.
Here I have some years stored in $key.(for example 1996 1997 etc)
Now, there are some companies for which these are the years.
So suppose I take first company as an example, I may get 1996 and 1997
years for it.
If I select second company, it may have 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999 years for it.

I can select range of years from my from and to select scrollbars.
I took it as $fromyear adn $toyear
if company has all the years from this range are present
then I m putting in front of company in a table.
if some years are absent for any specific company
then I m putting blank spaces in front of comapny in a table.

I have written this code:
foreach my $key(reverse sort keys %hash){
$i = $toyear;
while($i>=$fromyear){
if($key == $i){
print "<td>$hash{$key}</td>";
last;
}else{
print "<td> </td>";
}
$i--;
}
}

But I didnt get desired output.

Can u help me out?

Sponsored Links







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

Copyright 2009 codecomments.com