X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=perl-module%2FExamples.pod;fp=perl-module%2FExamples.pod;h=eba537c81f51901d48b2b78ff1a41a8f1e77c96f;hb=facb4a1ad3c9e8b2cdf55824680eed2afb91aebe;hp=fb53d085721aee0fdcffb9b9d306cf2a0d36c7b3;hpb=a70857ce808bba36e67a66375290e340dcf75adc;p=pspp diff --git a/perl-module/Examples.pod b/perl-module/Examples.pod index fb53d08572..eba537c81f 100644 --- a/perl-module/Examples.pod +++ b/perl-module/Examples.pod @@ -2,20 +2,20 @@ =for comment PSPP - a program for statistical analysis. =for comment Copyright (C) 2019 Free Software Foundation, Inc. -=for comment +=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 =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 =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. @@ -23,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; @@ -45,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) ); @@ -76,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) ); @@ -92,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) ); @@ -113,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