X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=perl-module%2FExamples.pod;h=eba537c81f51901d48b2b78ff1a41a8f1e77c96f;hb=refs%2Fheads%2Fctables10;hp=cb286ca19c12dbef9c6966888f4555d05da49c26;hpb=16c87013538d6662f30870e9bf73462f726524f9;p=pspp diff --git a/perl-module/Examples.pod b/perl-module/Examples.pod index cb286ca19c..eba537c81f 100644 --- a/perl-module/Examples.pod +++ b/perl-module/Examples.pod @@ -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 . + =head1 PSPP::Examples This page shows some simple examples of using the PSPP module. @@ -7,7 +23,7 @@ See L for details on each of the subroutines. =head2 A Simple example -This example creates a system file called F, containing one +This example creates a system file called F, containing one variable called "id". It contains no data. use PSPP; @@ -29,7 +45,7 @@ Their formats are F2.0, A80 and DATETIME17 respectively. my $dict = PSPP::Dict->new (); PSPP::Var->new ($dict, "id", (fmt=>PSPP::Fmt::F, width=>2, decimals=>0) ); - + PSPP::Var->new ($dict, "name", (fmt=>PSPP::Fmt::A, width=>80) ); PSPP::Var->new ($dict, "dob", (fmt=>PSPP::Fmt::DATETIME) ); @@ -60,7 +76,7 @@ This example creates a file with 3 cases. use PSPP; my $dict = PSPP::Dict->new (); - PSPP::Var->new ($dict, "id", + PSPP::Var->new ($dict, "id", (fmt=>PSPP::Fmt::F, width=>2, decimals=>0) ); PSPP::Var->new ($dict, "name", (fmt=>PSPP::Fmt::A, width=>8) ); @@ -76,19 +92,19 @@ This example creates a file with 3 cases. =head2 Variables with differing input and output formats By default, a variable's output format corresponds to the input format. -However, the output format may be changed after the variable has +However, the output format may be changed after the variable has been created. This example shows how to create a DATETIME variable using the current time -as its value. Since pspp uses a different epoch to perl, the constant -PSPP::PERL_EPOCH needs to be added to the value returned from time(), in order +as its value. Since pspp uses a different epoch to perl, the constant +PSPP::PERL_EPOCH needs to be added to the value returned from time(), in order that it be correctly represented by pspp. use PSPP; my $dict = PSPP::Dict->new (); - my $var1 = PSPP::Var->new ($dict, "entrytime", + my $var1 = PSPP::Var->new ($dict, "entrytime", (fmt=>PSPP::Fmt::F) ); $var1->set_output_format ( (fmt=>PSPP::Fmt::DATETIME, width=>20) ); @@ -97,9 +113,9 @@ that it be correctly represented by pspp. my $now = time (); - $sysfile->append_case ( [ $now + PSPP::PERL_EPOCH] ) + $sysfile->append_case ( [ $now + PSPP::PERL_EPOCH] ) || die "Cant write case"; - + $sysfile->close(); =head2 Reading data @@ -143,4 +159,4 @@ Reading of data must be done sequentially using the C method. } -=cut \ No newline at end of file +=cut