perl-module: Add copyright and licence notices to all files
[pspp] / perl-module / Examples.pod
index fc3f016777dee06431fbb53a9dfaac40f74a269b..fb53d085721aee0fdcffb9b9d306cf2a0d36c7b3 100644 (file)
@@ -1,5 +1,21 @@
 =pod
 
+=for comment PSPP - a program for statistical analysis.
+=for comment Copyright (C) 2019 Free Software Foundation, Inc.
+=for comment 
+=for comment This program is free software: you can redistribute it and/or modify
+=for comment it under the terms of the GNU General Public License as published by
+=for comment the Free Software Foundation, either version 3 of the License, or
+=for comment (at your option) any later version.
+=for comment 
+=for comment This program is distributed in the hope that it will be useful,
+=for comment but WITHOUT ANY WARRANTY; without even the implied warranty of
+=for comment MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+=for comment GNU General Public License for more details.
+=for comment 
+=for comment You should have received a copy of the GNU General Public License
+=for comment along with this program.  If not, see <http://www.gnu.org/licenses/>.
 =head1 PSPP::Examples
 
 This page shows some simple examples of using the PSPP module.
@@ -102,4 +118,45 @@ that it be correctly represented by pspp.
        
        $sysfile->close();
 
-=cut
\ No newline at end of file
+=head2  Reading data
+
+Data can be read from a system file or other source:
+
+       use PSPP;
+
+       my $sf = PSPP::Reader->open ("foo.sav");
+
+       my $dict = $sf->get_dict ();
+
+
+Once opened, the dictionary can be used like any other.
+
+       for ($v = 0 ; $v < $dict->get_var_cnt() ; $v++)
+       {
+           my $var = $dict->get_var ($v);
+
+           # Print the variables
+           my $name = $var->get_name ();
+           my $label = $var->get_label ();
+           print "Var: $name, Label: $label\n";
+
+           # Retrieve and print the value labels
+           my $vl = $var->get_value_labels ();
+           print "$_: $vl->{$_}\n" for keys %$vl;
+       }
+
+
+Reading of data must be done sequentially using the C<get_next_case> method.
+
+       while (my $c = $sf->get_next_case () )
+       {
+           my $v;
+           for ($v = 0; $v < $dict->get_var_cnt(); $v++)
+           {
+               print "val$v: @$c[$v] ";
+           }
+           print "\n";
+       }
+
+
+=cut