perl - formatting output data to an excel file -


this program gets numeric values web each of values in @values array want these values printed out in table looks like

       il9  il8 il7  2012  v1    b1  2011  v2    b2  2010  v3    b3    .    .  2000  v12   b12 

where v1 .. v12 values first variable in @values etc. here program please me structure it. there escape character take me first line of program in perl thanks

  #!/usr/bin/perl -w   use strict;   use lwp::useragent;   use uri;   $browser = lwp::useragent->new;   $browser->timeout(10);   $browser->env_proxy;    open(out, ">out");   $i = 2013;   while ($i-- > 2000){print out "$i\n"}   $a = 2013 ;   $base = 'http://webtools.mf.uni-lj.si/public/summarisenumbers.php';   @values = ('il9', 'il8', 'il6' );   foreach $value (@values) { print out "$value \n"     while ($a-- > 2000){                 $b = $a + 1;                 $c = $b + 1;                  $query = '?query=('.$value.')'.$a.'[dp] not           '.$b.'[dp] not '.$c.'[dp]';                 $add = $base.$query;                 #my $url = uri->new($add);                   #my $response = $browser->get($url);                  #if($response->is_success) {print out $response->decoded_content;}                 #else {die $response->status_line};                 print out "$query\n";                 } $a = 2013; print out                         }     close(out); 

pay more attention formatting/indentation , variable naming - lot.

#!/usr/bin/perl  use strict; use warnings; use lwp::useragent;  $base_url  = 'http://webtools.mf.uni-lj.si/public/summarisenumbers.php'; @values    = ( 'il9', 'il8', 'il6' ); $stat_data = {};  $browser = lwp::useragent->new; $browser->timeout(10); $browser->env_proxy;  $value ( @values ) {      $year ( 2010 .. 2013 ) {          $query = '?query=(' . $value . ')' . $year .'[dp] not           ' . ($year+1) . '[dp] not ' . ($year+2) .'[dp]';         $url   = "$base_url$query";          $response = $browser->get( $url );          if( $response->is_success ) {             ## store fetched content in hash structure             $stat_data->{$year}->{$value} = $response->decoded_content;         }         else {             die $response->status_line;         }     } }  ## print header print "\t", join( "\t", @values ), "\n";  ## print data years in reverse order $year ( reverse sort keys %{$stat_data} ) {      print $year;      $value ( @values ) {         print "\t", $stat_data->{$year}->{$value};     }      print "\n"; } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -