[csw-devel] SF.net SVN: gar:[16602] csw/mgar/gar/v2/lib/web

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Tue Dec 27 19:10:18 CET 2011


Revision: 16602
          http://gar.svn.sourceforge.net/gar/?rev=16602&view=rev
Author:   wahwah
Date:     2011-12-27 18:10:18 +0000 (Tue, 27 Dec 2011)
Log Message:
-----------
An example of processing catalog data in Perl

Added Paths:
-----------
    csw/mgar/gar/v2/lib/web/examples/
    csw/mgar/gar/v2/lib/web/examples/catalog_data.pl

Added: csw/mgar/gar/v2/lib/web/examples/catalog_data.pl
===================================================================
--- csw/mgar/gar/v2/lib/web/examples/catalog_data.pl	                        (rev 0)
+++ csw/mgar/gar/v2/lib/web/examples/catalog_data.pl	2011-12-27 18:10:18 UTC (rev 16602)
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+#
+# This is a minimal example how to read a process catalog data via the
+# REST interface. The idea is that you fetch data from a specific URL,
+# which is a JSON representation of a data structure. You decode the
+# structure, and you're ready to process it.
+#
+# In this example, the data structure read is one package catalog.
+
+use warnings;
+
+use LWP::Simple;
+use JSON;
+use Data::Dumper;
+
+my $url = 'http://buildfarm.opencsw.org/pkgdb/rest/catalogs/unstable/sparc/SunOS5.9/';
+# More URL patterns at: http://buildfarm.opencsw.org/pkgdb/
+my $json_string = get $url;
+die "Couldn't get $url" unless defined $json_string;
+my $catalog_data = decode_json $json_string;
+# You can process the catalog data here.
+print Dumper($catalog_data);

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list