<rss version="2.0"><channel><title>Newest perlmonks questions</title><link>http://perlmonks.org</link><description>Recent questions to the perlmonks.org site (maintained by zigdon)</description><language>en-us</language><lastBuildDate>Thu, 23 May 2013 22:05:05 -0400</lastBuildDate><managingEditor>rss@peeron.com</managingEditor><pubDate>Thu, 23 May 2013 22:05:05 -0400</pubDate><webMaster>webmaster@peeron.com</webMaster><ttl>5</ttl><item><title>
Client-Side HTTP Handlers</title><author>
konnjuta &lt;dummy@example.com&gt;</author><guid>http://perlmonks.org/index.pl?node_id=1035041</guid><link>http://perlmonks.org/index.pl?node_id=1035041</link><pubDate>Thu, 23 May 2013 20:05:19 -0400</pubDate><description><![CDATA[
<p>I've got a closed source client/server software that communicate through HTTP. Unfortunately, neither the client nor the server has any authentication module for HTTP communication.</p>

<p>To overcome this I've set up an nginx proxy on the server. However I still need a HTTP handler clientside to capture all outgoing client requests and manipulate it to encompass the authentication mechanism used by the proxy.</p>

How can I use Perl to do this?
]]></description></item><item><title>
Win32::GUI make file test fail</title><author>
hurnhu &lt;dummy@example.com&gt;</author><guid>http://perlmonks.org/index.pl?node_id=1035040</guid><link>http://perlmonks.org/index.pl?node_id=1035040</link><pubDate>Thu, 23 May 2013 19:05:49 -0400</pubDate><description><![CDATA[
<p>bean trying to install Win32::GUI, have tried force, uninstalled and reinstall of strawberry, tried to build it, but here is the error i get when i cpan Win32::GUI</p>

<code>
In file included from Scintilla.xs:8:0:
../GUI.h:768:22: warning: 'ImageList_Duplicate' redeclared without dllimport att
ribute: previous dllimport ignored [-Wattributes]
Scintilla.xs: In function 'CallWndProc':
Scintilla.xs:199:101: error: 'GWL_USERDATA' undeclared (first use in this functi
on)
Scintilla.xs:199:101: note: each undeclared identifier is reported only once for
 each function it appears in
dmake:  Error code 129, while making 'Scintilla.o'
dmake.exe:  Error code 255, while making 'subdirs'
  ROBERTMAY/Win32-GUI/Win32-GUI-1.06.tar.gz
  C:\strawberry\c\bin\dmake.exe -- NOT OK
CPAN: YAML::XS loaded ok (v0.39)
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Stopping: 'install' failed for 'Win32::GUI'.
</code>

<p>perl vr: 5.16.3</p>
]]></description></item><item><title>
How do I synchronize data to common timestamp</title><author>
lewnewby &lt;dummy@example.com&gt;</author><guid>http://perlmonks.org/index.pl?node_id=1035037</guid><link>http://perlmonks.org/index.pl?node_id=1035037</link><pubDate>Thu, 23 May 2013 18:05:47 -0400</pubDate><description><![CDATA[
<p>Let me get this over up front, I am a relatively new perl user (Starting over after 15 years).</p>

<p>I have been working on extracting data from a management server via an API supplied by the vendor. So far that is all working great, I am able to get the data. My problem arises in that when I receive the data it will have some odd offset in the time stamps.</p>

<p>I make a call requesting data at the default sample rate of 60 seconds over a period of 1 day. The API returns the data in a sequence of Key:Value pairings for each counter I am retrieving. The first counter may have X secs:Value and proceed through at 60 second increments. Ok great so far, the second and forth counters may return to the top with the first and X is the time stamp but the third counter returns to the top and may be X+6 secs instead of X.</p>

<p>The data ends up looking like this:</p>

<code>
2013-05-21 18:46:44,221.667,9.041,92.133,4.008,84.450,6.220,8.983,2.570,5.917,6.710,87.067,6.133
2013-05-21 18:46:45,7.519,5.069
2013-05-21 18:47:44,33.617,2.817,70.900,2.931,161.000,9.811,8.233,2.280,5.617,6.010,86.117,8.108,6.067,5.304
2013-05-21 18:48:44,26.417,1.758,38.933,2.550,42.900,3.526,5.750,1.515,4.867,6.132,86.433,6.067
2013-05-21 18:48:45,7.562,5.068
2013-05-21 18:49:44,42.683,2.308,33.633,2.208,42.983,3.807,6.033,1.751,4.900,6.042,87.300,8.118,5.983,5.207
2013-05-21 18:50:44,86.983,8.791,103.417,7.851,62.900,8.295,15.500,4.421,8.300,9.368,87.800,7.697,6.050,5.202
2013-05-21 18:51:44,50.033,2.840,63.350,3.071,36.817,3.134,6.217,1.480,4.783,5.444,88.433,6.150
2013-05-21 18:51:45,7.725,5.275
2013-05-21 18:52:44,50.017,3.071,61.033,2.538,45.317,4.027,6.233,1.769,4.767,5.653,88.383,8.086,5.550,4.966
2013-05-21 18:53:44,38.850,2.265,43.100,2.051,42.683,3.795,5.883,1.403,4.850,5.667,89.700,6.000
2013-05-21 18:53:45,7.164,5.061
2013-05-21 18:54:44,22.000,1.741,42.817,2.352,41.700,3.430,5.700,1.543,5.567,5.756,87.517,7.939,6.300,5.188
2013-05-21 18:55:44,62.700,6.359,78.267,6.949,58.883,6.804,12.350,3.601,8.200,9.379,87.550,7.349,6.017,5.114
</code>

<p>I would like it to look like this:

</p>
<code>
2013-05-21 18:47:00,30.400,2.157,9.900,1.315,39.917,4.201,6.383,1.798,5.167,7.250,129.950,7.965,5.667,4.892
2013-05-21 18:48:00,33.917,2.276,7.017,1.052,40.150,3.489,5.233,1.440,4.900,6.393,129.850,8.257,6.033,5.191
2013-05-21 18:49:00,31.867,2.567,10.367,1.337,45.467,4.138,6.417,1.796,5.267,7.148,124.867,8.340,5.983,4.897
2013-05-21 18:50:00,57.533,2.943,8.800,1.063,41.867,3.701,5.083,1.445,4.900,6.176,129.517,7.715,5.867,4.925
2013-05-21 18:51:00,72.900,10.128,103.833,6.560,66.317,6.734,14.933,4.398,11.267,11.092,119.767,7.753,6.100,5.121
2013-05-21 18:52:00,23.950,1.803,7.217,1.460,50.667,3.845,5.183,1.492,4.583,5.481,124.500,9.369,6.017,5.030
2013-05-21 18:53:00,25.500,1.910,9.767,1.754,49.467,4.112,6.133,1.772,23.117,17.196,127.583,8.158,6.067,5.076
2013-05-21 18:54:00,47.350,2.344,8.833,1.419,47.283,3.875,5.400,1.409,4.867,6.035,148.567,8.428,5.883,4.940
2013-05-21 18:55:00,29.067,2.338,10.400,1.789,45.067,3.250,6.233,1.795,5.100,5.866,126.517,7.990,6.133,5.219
</code>

<p>Here is the code I am using to do this:</p>

<code>
	my ($list, $obj, $server_ctx) = @_;

	my @objList = @{ $list };
	my (@counter_arr,$objName,@perf_cnt_data,%perfhash);
	my $gen_time_arr = 1;
	my $gen_hash_hdr = 1;
	my $obj_i = 0;
	my ($rec,$tmpHDR,$tmpVAL);
	if ($obj eq "system") {
		$obj = "host";
	}

	$perfhash{"Time"} = "";
	foreach my $perf_out ( @objList ){
		my $instance = $perf_out->child_get("perf-instances");
		my @instances = $instance->children_get("perf-instance-counter-data");

		foreach $rec (@instances){
			my $obj_id = $rec->child_get_string("object-id");

			my $IterStart = NaElement->new("$obj" . "-list-info-iter-start");
			$IterStart->child_add_string("object-name-or-id","$obj_id");

			my $output = $server_ctx->invoke_elem($IterStart);
			if ( $output -> results_status()=~/failed/ ) {
				print "\n\n\tFailed to get list of $obj: Error: ".$output->results_reason(). "\n\n";
			} else {
				my $records = $output->child_get_int("records");
				my $tag = $output->child_get_string("tag");

				$output = $server_ctx->invoke("$obj" . "-list-info-iter-next", "maximum", $records, "tag", $tag);
				if ( $output -> results_status()=~/failed/ ) {
					print "\n\n\tFailed to iterate list of $obj : Error: ".$output->results_reason(). "\n\n";
				}
			}
			my $aggregates = $output->child_get("$obj" . "s");
			my @aggregateArr = $aggregates->children_get();
			foreach my $aggr (@aggregateArr) {
				$objName = $aggr->child_get_string("$obj" . "-name");
				$objName =~ s/\///g;
			}

			my $counters = $rec->child_get("counters");
			@perf_cnt_data = $counters->children_get("perf-counter-data");
			my $rec1;
# TODO If the counter is aggregate:pa_max_disk_busy and returns nothing get the max of disk:disk_busy for the aggregate
			foreach $rec1 (@perf_cnt_data) {
				my $counter_name = $rec1->child_get_string("counter-name");
				my $counter_str = $rec1->child_get_string("counter-data");
				my @counter_arr = split (',', $counter_str);
				my $colName = $objName . ":" . $counter_name;
				chomp($colName);
				$tmpHDR = $perfhash{"Time"};
				$perfhash{"Time"} = join( ',' , $tmpHDR , $colName);
				for (@counter_arr) {
					my ($time,$value) = split(':',$_);
					my @timestamp = ( localtime($time) )[0..5];
					$time = POSIX::strftime( '%F %H:%M:%S', @timestamp);
					if ($gen_time_arr == 1) {
						$perfhash{$time} = join('' , "," , $value);
						$gen_time_arr = 0;
					}else {
						if ($perfhash{$time}) {
							$tmpVAL = $perfhash{$time};
						} else {
							$tmpVAL = "";
						}
						$perfhash{$time} = join( ',' , $tmpVAL , $value);
					}
				}
			}
		}
	}
	return(\%perfhash);
}
</code>

<p>Thanks in advance</p>
<p>Lew</p>]]></description></item><item><title>
Equivalent for delayed_job?</title><author>
parkan &lt;dummy@example.com&gt;</author><guid>http://perlmonks.org/index.pl?node_id=1035035</guid><link>http://perlmonks.org/index.pl?node_id=1035035</link><pubDate>Thu, 23 May 2013 18:05:10 -0400</pubDate><description><![CDATA[
<p>I need to run background tasks at arbitrary points in the future, with queue behavior if multiple execute at or near the same time, ability to manipulate the task list, retry (ideally with exponentially longer retry window), etc.</p>

<p>In Ruby, there is <a href="https://github.com/tobi/delayed_job">delayed_job</a> (and php port djjob), which does this pretty much perfectly.</p>

<p>The closest Perl solution I could find was Beanstalk::Job, but this doesn't appear to support execution in the "far future" (next week). There is also Schedule::At, which does (and also allows manipulation of the tasks) but it runs external commands and the jobs appear to be executed straight with no queueing mechanism</p>

Is there something that's more like delayed_job? Do I need to roll my own?

Also: beanstalkd appears to be memory resident, mostly, and I'd prefer to have a db/disk backed queue ]]></description></item><item><title>
pagination script to work with SQL server</title><author>
pearlgirl &lt;dummy@example.com&gt;</author><guid>http://perlmonks.org/index.pl?node_id=1035024</guid><link>http://perlmonks.org/index.pl?node_id=1035024</link><pubDate>Thu, 23 May 2013 16:05:40 -0400</pubDate><description><![CDATA[
Hi everyone,
I'm using this script for pagination: <code>declare \@limit int 
declare \@offset int 
set \@offset = $offset; 
set \@limit = $limit; 
declare \@idxini int 
declare \@idxfim int 
select \@idxfim = \@offset * \@limit 
select \@idxini = \@idxfim - (\@limit-1); 
WITH paging AS 
( 
  SELECT 
  ROW_NUMBER() OVER (order by table_ID) AS rowid, *
  FROM table
 
) 
select * 
from paging 
where rowid between \@idxini and \@idxfim 
order by rowid; ;
END_ROW2</code> I need to add joins, and specify other columns besides rowid and *, but it stops working ( no results returned) as soon as I modify it from the format below. It HAS to be 1 table and it HAS to be "select rowid, *"...  Even just removing the * stops it from working.  I tried running different variations of the script in SQL Server (joining other tables, changing columns, etc.) and it works just fine. It's only within the perl file that it starts acting finicky.  I have no idea why. Can someone help me, please?  Any recommendations on other pagination scripts that work with SQL Server are welcome too.
Thank you!
 ]]></description></item></channel></rss>
