[csw-devel] SF.net SVN: gar:[16454] csw/mgar

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Dec 11 00:05:54 CET 2011


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

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

Added: csw/mgar/lib/web/examples/catalog_data.pl
===================================================================
--- csw/mgar/lib/web/examples/catalog_data.pl	                        (rev 0)
+++ csw/mgar/lib/web/examples/catalog_data.pl	2011-12-10 23:05:54 UTC (rev 16454)
@@ -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