I'm not really trying to print, I was just using that as an example. I apologize for not being specific enough. My code is below and I'm basically opening a file and storing it into an array. I then take the first column and query our Quickbase database to return the primary key, then I map that primary key to @data and import back into Quickbase.
The problem is I can only do the gen_results_table call for a 100 stores at a time, so I have to run that gen_results_table statement once for every 100 stores.
#!/usr/bin/perl
require 'c:/quickbase.pm';#REF Perl SDK
use LWP;
my $url = "http://somesite.com/forcast.txt";
my $ua = LWP::UserAgent->new();
$ua->proxy(['http'],'http://ourproxy.oursite.com:80');
$ua->credentials($netloc, $realm, $uname, $pass);
my $response = $ua->get($url);
open (FILE, ">C:\\snow.txt") || die "Can't open Snow.txt $!\n";
print FILE $response->content;
close(FILE);
open (FILE, "<C:\\snow.txt") || die "Can't open Snow.txt $!\n";
my $column=0;
while ($line = <FILE>){
chomp($line);
push @data, [split /\t/,$line];
}
close(FILE);
@column = map {$$_[0]} @data;
shift(@column);
$stores = join( ' OR ',@column);
my $qdb = HTTP::QuickBase->new();
$qdb->proxy('http://ourproxy.oursite.com:80');
$qdb->url_prefix("https://www.quickbase.com/db");
$qdb->authenticate("MyUserName","MyPass");
$qdb->apptoken('bj6azdybdeg8akbcu5ggabfdedsi');
my $recid=$qdb->gen_results_table("babvce7n4",{query=>"{'6'.EX.$stores
+}",clist=>"3",options=>"csv"});
my @recids = split /\n|\r\n/,$recid;
my $i = 0;
@data = map{unshift(@{$_},$recids[$i++]);$_} @data;
$a = join( "\n", map {join(',',@{$_})} @data);
my $import = $qdb->import_from_csv("bhabcde7f",$a,"6.7.8.9.10.11.12.13
+.14.15.16.17.18.19.20.21.22.23.24.25","1");
Keep in mind I am new to Perl
-
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.