Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: While Loops

by CountZero (Bishop)
on Jan 08, 2013 at 19:54 UTC ( #1012326=note: print w/replies, xml ) Need Help??

in reply to While Loops

Wait. Stop. Take one step back and ask yourself "Why do I need to print the records 100 at a time"?

In the end there is no difference between printing the records as soon as they are read in, or waiting till the end and then printing them all at once, or anything else in between these two extremes. The end is that you have a screen (or several screens) full of data.

Output is usually buffered anyhow, so printing in "blocks" of 100 is unlikely to speed things up or make your program more performant.


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: While Loops
by Anonymous Monk on Jan 08, 2013 at 20:29 UTC

    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:/';#REF Perl SDK use LWP; my $url = ""; my $ua = LWP::UserAgent->new(); $ua->proxy(['http'],''); $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(''); $qdb->url_prefix(""); $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," +.","1");

    Keep in mind I am new to Perl

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012326]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-05-23 00:35 GMT
Find Nodes?
    Voting Booth?