[32771] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4035 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 16 21:09:35 2013

Date: Mon, 16 Sep 2013 18:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 16 Sep 2013     Volume: 11 Number: 4035

Today's topics:
    Re: [OT] scoping <xhoster@gmail.com>
    Re: [OT] scoping <rweikusat@mssgmbh.com>
    Re: Replace an occurrence of a regexp with a function c <ben.usenet@bsb.me.uk>
    Re: Replace an occurrence of a regexp with a function c <ben.usenet@bsb.me.uk>
    Re: Replace an occurrence of a regexp with a function c <ben@morrow.me.uk>
        Replace an occurrence of a regexp with a function call  <davidmichaelkarr@gmail.com>
    Re: Replace an occurrence of a regexp with a function c <davidmichaelkarr@gmail.com>
    Re: Replace an occurrence of a regexp with a function c <davidmichaelkarr@gmail.com>
        Return values of boolean operators (Tim McDaniel)
    Re: Return values of boolean operators <peter@makholm.net>
    Re: Return values of boolean operators <bill@todbe.com>
    Re: Return values of boolean operators (Tim McDaniel)
    Re: Return values of boolean operators (Tim McDaniel)
    Re: Return values of boolean operators <ben@morrow.me.uk>
    Re: Return values of boolean operators <news@todbe.com>
        The old-fashioned guestbook <tuxedo@mailinator.com>
    Re: The old-fashioned guestbook <sbryce@scottbryce.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 15 Sep 2013 19:23:29 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: [OT] scoping
Message-Id: <l15r7u$e0d$3@dont-email.me>

On 09/15/13 16:16, David Harmon wrote:
> On Sun, 14 Jul 2013 17:34:50 +0200 in comp.lang.perl.misc, "Dr.Ruud"
> <rvtol+usenet@xs4all.nl> wrote,
>> On 14/07/2013 17:11, Tim McDaniel wrote:
>>> In article <i7haba-e8u.ln1@anubis.morrow.me.uk>,
>>> Ben Morrow  <ben@morrow.me.uk> wrote:
>>>> Quoth "Dr.Ruud" <rvtol+usenet@xs4all.nl>:
>>
>>>>>        qq{
>>>>>            SELECT
>>>>>                $columns_csv
>>>>>            FROM
>>>>>                $table
>>>>>            WHERE
>>>>>                id IN (@ids)  -- hundreds easily
>>>>
>>>> Please, someone tell your cow-orkers about placeholders...
>>>
>>> The classic "Bobby Tables" strip:
>>> http://xkcd.com/327/
>>
>> Yeah, also doesn't apply.
>>
>> See how I left out what @ids is. Now, in stead of assuming anything else
>> again, assume that @ids can only contain numbers, and that each is
>> between 1 and some maximum.
>
> Uhm, no.  When evaluating whether code is broken or not, you don't
> assume perfect flawless input.  You assume worst case malicious NSA
> type input.
>

Fascinating.  So no matter how much validating I've done of the data, I 
have to assume that the data has not been validated.  Do I get an 
exemption from this if the data was consumed and validated with no 
semicolons intervening?  How about no newlines intervening?  None of either?

Xho





------------------------------

Date: Mon, 16 Sep 2013 10:46:31 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [OT] scoping
Message-Id: <87mwnd2j60.fsf@sable.mobileactivedefense.com>

David Harmon <source@netcom.com> writes:
> On Sun, 14 Jul 2013 17:34:50 +0200 in comp.lang.perl.misc, "Dr.Ruud"
> <rvtol+usenet@xs4all.nl> wrote,
>>On 14/07/2013 17:11, Tim McDaniel wrote:
>>> In article <i7haba-e8u.ln1@anubis.morrow.me.uk>,
>>> Ben Morrow  <ben@morrow.me.uk> wrote:
>>>> Quoth "Dr.Ruud" <rvtol+usenet@xs4all.nl>:
>>
>>>>>       qq{
>>>>>           SELECT
>>>>>               $columns_csv
>>>>>           FROM
>>>>>               $table
>>>>>           WHERE
>>>>>               id IN (@ids)  -- hundreds easily
>>>>
>>>> Please, someone tell your cow-orkers about placeholders...
>>>
>>> The classic "Bobby Tables" strip:
>>> http://xkcd.com/327/
>>
>>Yeah, also doesn't apply.
>>
>>See how I left out what @ids is. Now, in stead of assuming anything else 
>>again, assume that @ids can only contain numbers, and that each is 
>>between 1 and some maximum.
>
> Uhm, no.  When evaluating whether code is broken or not, you don't
> assume perfect flawless input.  You assume worst case malicious NSA
> type input.

The code is 'broken' when it doesn't process the data it is supposed to
process such that the intended result results from that. Eg, this

sub sum
{
    return $_[0] + $_[1];
}

is a function which will return the sum of its first two arguments
provided that both are numbers. It can be made to do something very much
different,

---------
package Ha;

use overload "+" => negate;

sub new
{
    return bless([], $_[0]);
}

sub negate
{
    return ~$_[1];
}

package main;

sub sum
{
    return $_[0] + $_[1];
}

print(sum(3, 4), "\n");
print(sum(Ha->new(), 4), "\n");
---------

but this doesn't mean 'sum is broken': The precondition 'first two
arguments are numbers' is not true for the second call, hence, the
postcondition won't necessarily be true afterwards.

Whether or not 'will be a number > 1' is a sensible precondition in a
given situtation would be a different question.


------------------------------

Date: Mon, 16 Sep 2013 20:02:05 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Replace an occurrence of a regexp with a function call on a substring of the match, multiple times on the line, multiple lines in a file
Message-Id: <0.9bd278c0a34db0d5f11b.20130916200205BST.874n9ktwsy.fsf@bsb.me.uk>

David Karr <davidmichaelkarr@gmail.com> writes:

> I have a pattern in an input file that looks like this:
>
>     latestTime="1379353492000"
>
> I need to replace this with something like this:
>
>     latestTime="2013-09-16 10:34:33"
>
> This pattern will occur in multiple lines in a file, and multiple
> times on a single line.
>
> The hardest part of this seems to be to pass the milliseconds value
> into "strftime" as the replacement portion of the substitution regexp,
> for each occurrence. I can't get this to work.
>
> This is what I have so far, and I hope I don't have to use that very
> strange syntax to call a function in the string (I found some
> references with examples like this):
>
> #! /bin/perl
> use English;
> use strict;
> use POSIX qw( strftime );
>
> $| = 1;

You probably don't need this (if you do, nothing in your problem
description suggest that you do).  Also, since you "use English" it's
odd to then use the cryptic name for this variable.  It's
$OUTPUT_AUTOFLUSH with "use English".

> while (my $line = <STDIN>) {
>     if ($line =~ /(^.*latestTime=")([0-9]+)(".*$)/) {

You don't have to match the lines first -- just try the substitution you
want to do.  Also, Perl has \d with is often better than writing [0-9].

> "\n";
> 	$line =~ s/latestTime="([0-9]+)"/latestTime="${\strftime("%Y-%m-%d %H:%M:%S", localtime($1/1000))}"/g';

You can use the "e" modifier to permit an expression in a substitution,
and you can put the whole text into strftime's format to get a simpler
expression:

    $line =~ s!latestTime="(\d+)"!
               strftime("latestTime=\"%Y-%m-%d %H:%M\"",
                        localtime($1/1000))!eg;

Because it's an expression, you can be free with the layout.

>     }
>     print $line;
> }

Finally, this pattern of looping and printing is so common that Perl
provides a command-line options for it.  You can therefore write this
sort of thing as a single command, should that be more convenient than a
script:

  perl -MPOSIX -pe 's/\d+/strftime("%F", localtime($1))/eg'

(using a simplified example).

-- 
Ben.


------------------------------

Date: Mon, 16 Sep 2013 21:22:42 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Replace an occurrence of a regexp with a function call on a substring of the match, multiple times on the line, multiple lines in a file
Message-Id: <0.155e2f6575de8553e15c.20130916212242BST.87y56wsei5.fsf@bsb.me.uk>

David Karr <davidmichaelkarr@gmail.com> writes:

> On Monday, September 16, 2013 12:02:05 PM UTC-7, Ben Bacarisse wrote:
>> David Karr <davidmichaelkarr@gmail.com> writes:
>> You can use the "e" modifier to permit an expression in a substitution,
<snip>
> I find this "e" directive curious.  I can't find this documented
> anywhere.  Is there a good reference for that?

It's documented in "perlop" as part of the documentation of s///.
Technically it's called a modifier or an option (the latter was a
surprise to me but it's one of the terms used in the documentation).

-- 
Ben.


------------------------------

Date: Tue, 17 Sep 2013 00:17:13 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Replace an occurrence of a regexp with a function call on a substring of the match, multiple times on the line, multiple lines in a file
Message-Id: <p4gkga-fh22.ln1@anubis.morrow.me.uk>


Quoth Ben Bacarisse <ben.usenet@bsb.me.uk>:
> 
>     $line =~ s!latestTime="(\d+)"!
>                strftime("latestTime=\"%Y-%m-%d %H:%M\"",
>                         localtime($1/1000))!eg;

 ...or, avoiding the backwhacks, and making the code look more like code:

    $line =~ s{latestTime="(\d+)"}{ 
        strftime(
            qq/latestTime="%Y-%m-%d %H:%M"/,
            localtime($1/1000)
        )
    }eag;

The /a requires 5.14, and restricts the \d match to ASCII, which is
probably what you want.

Ben



------------------------------

Date: Mon, 16 Sep 2013 11:09:11 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Replace an occurrence of a regexp with a function call on a substring of the match, multiple times on the line, multiple lines in a file
Message-Id: <d5f38083-9f17-46a9-889d-8d06c43326b5@googlegroups.com>

I have a pattern in an input file that looks like this:

    latestTime="1379353492000"

I need to replace this with something like this:

    latestTime="2013-09-16 10:34:33"

This pattern will occur in multiple lines in a file, and multiple times on a single line.

The hardest part of this seems to be to pass the milliseconds value into "strftime" as the replacement portion of the substitution regexp, for each occurrence. I can't get this to work.

This is what I have so far, and I hope I don't have to use that very strange syntax to call a function in the string (I found some references with examples like this):

#! /bin/perl
use English;
use strict;
use POSIX qw( strftime );

$| = 1;

while (my $line = <STDIN>) {
    if ($line =~ /(^.*latestTime=")([0-9]+)(".*$)/) {
"\n";
	$line =~ s/latestTime="([0-9]+)"/latestTime="${\strftime("%Y-%m-%d %H:%M:%S", localtime($1/1000))}"/g';
    }
    print $line;
}




------------------------------

Date: Mon, 16 Sep 2013 12:57:04 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Re: Replace an occurrence of a regexp with a function call on a substring of the match, multiple times on the line, multiple lines in a file
Message-Id: <0a98dcb9-9c15-45ee-9986-532f41992b83@googlegroups.com>

On Monday, September 16, 2013 12:02:05 PM UTC-7, Ben Bacarisse wrote:
> David Karr <davidmichaelkarr@gmail.com> writes:
> 
> 
> 
> > I have a pattern in an input file that looks like this:
> 
> >
> 
> >     latestTime="1379353492000"
> 
> >
> 
> > I need to replace this with something like this:
> 
> >
> 
> >     latestTime="2013-09-16 10:34:33"
> 
> >
> 
> > This pattern will occur in multiple lines in a file, and multiple
> 
> > times on a single line.
> 
> >
> 
> > The hardest part of this seems to be to pass the milliseconds value
> 
> > into "strftime" as the replacement portion of the substitution regexp,
> 
> > for each occurrence. I can't get this to work.
> 
> >
> 
> > This is what I have so far, and I hope I don't have to use that very
> 
> > strange syntax to call a function in the string (I found some
> 
> > references with examples like this):
> 
> >
> 
> > #! /bin/perl
> 
> > use English;
> 
> > use strict;
> 
> > use POSIX qw( strftime );
> 
> >
> 
> > $| = 1;
> 
> 
> 
> You probably don't need this (if you do, nothing in your problem
> 
> description suggest that you do).  Also, since you "use English" it's
> 
> odd to then use the cryptic name for this variable.  It's
> 
> $OUTPUT_AUTOFLUSH with "use English".

Write Perl without cryptic syntax?  What? :)

Thanks for the more expressive way to do this, and reminding me that I don't need it for this script.

> > while (my $line = <STDIN>) {
> 
> >     if ($line =~ /(^.*latestTime=")([0-9]+)(".*$)/) {
> 
> 
> 
> You don't have to match the lines first -- just try the substitution you
> 
> want to do.  Also, Perl has \d with is often better than writing [0-9].
> 
> 
> 
> > "\n";
> 
> > 	$line =~ s/latestTime="([0-9]+)"/latestTime="${\strftime("%Y-%m-%d %H:%M:%S", localtime($1/1000))}"/g';
> 
> 
> 
> You can use the "e" modifier to permit an expression in a substitution,
> 
> and you can put the whole text into strftime's format to get a simpler
> 
> expression:
> 
> 
> 
>     $line =~ s!latestTime="(\d+)"!
> 
>                strftime("latestTime=\"%Y-%m-%d %H:%M\"",
> 
>                         localtime($1/1000))!eg;
> 
> 
> 
> Because it's an expression, you can be free with the layout.

Outstanding.  The "e" directive is definitely new to me.  I'll have to read about that.

> >     }
> 
> >     print $line;
> 
> > }
> 
> 
> 
> Finally, this pattern of looping and printing is so common that Perl
> 
> provides a command-line options for it.  You can therefore write this
> 
> sort of thing as a single command, should that be more convenient than a
> 
> script:
> 
> 
> 
>   perl -MPOSIX -pe 's/\d+/strftime("%F", localtime($1))/eg'

I'm writing this as a command-line filter tool, to be used with other filters, so I want the details in the script, not on the command line, but thanks for that option ayway.

> (using a simplified example).
> 
> 
> 
> -- 
> 
> Ben.



------------------------------

Date: Mon, 16 Sep 2013 13:07:11 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Re: Replace an occurrence of a regexp with a function call on a substring of the match, multiple times on the line, multiple lines in a file
Message-Id: <c4ee451a-5804-465f-8d14-7be607cf7658@googlegroups.com>

On Monday, September 16, 2013 12:02:05 PM UTC-7, Ben Bacarisse wrote:
> David Karr <davidmichaelkarr@gmail.com> writes:
> You can use the "e" modifier to permit an expression in a substitution,
> 
> and you can put the whole text into strftime's format to get a simpler
> 
> expression:
> 
>     $line =~ s!latestTime="(\d+)"!
>                strftime("latestTime=\"%Y-%m-%d %H:%M\"",
>                         localtime($1/1000))!eg;
> 
> Because it's an expression, you can be free with the layout.

I find this "e" directive curious.  I can't find this documented anywhere.  Is there a good reference for that?


------------------------------

Date: Mon, 16 Sep 2013 06:51:48 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Return values of boolean operators
Message-Id: <l169q4$ejb$1@reader1.panix.com>

OK, which man page is it that has documentation of the return values
of boolean operators?  1 and '', but I dimly recall that there's
something special about the particular '' returned for false, that it
avoids ... um, some kind of warning if ... something ...

-- 
Tim McDaniel, tmcd@panix.com


------------------------------

Date: Mon, 16 Sep 2013 09:16:59 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: Return values of boolean operators
Message-Id: <87ob7tb5hw.fsf@vps1.hacking.dk>

tmcd@panix.com (Tim McDaniel) writes:

> OK, which man page is it that has documentation of the return values
> of boolean operators?  1 and '', but I dimly recall that there's
> something special about the particular '' returned for false, that it
> avoids ... um, some kind of warning if ... something ...

See the perlop man page under the heading "Relational Operators".

Basically it returns a dualvar, not quite unlike what is returned by

  Scalar::Util::dualvar(0,"")

//Makholm


------------------------------

Date: Mon, 16 Sep 2013 02:32:30 -0700
From: "$Bill" <bill@todbe.com>
Subject: Re: Return values of boolean operators
Message-Id: <l16j7b$ke7$1@dont-email.me>

On 9/15/2013 23:51, Tim McDaniel wrote:
> OK, which man page is it that has documentation of the return values
> of boolean operators?  1 and '', but I dimly recall that there's
> something special about the particular '' returned for false, that it
> avoids ... um, some kind of warning if ... something ...

perlsyn man page:

   Truth and Falsehood
     The number 0, the strings '0' and '', the empty list "()", and "undef" are
     all false in a boolean context. All other values are true. Negation of a
     true value by "!" or "not" returns a special false value. When evaluated as
     a string it is treated as '', but as a number, it is treated as 0.

perldata man page:

Scalar Values
     A scalar value is interpreted as TRUE in the Boolean sense if it is not the
     null string or the number 0 (or its string equivalent, "0"). The Boolean
     context is just a special kind of scalar context where no conversion to a
     string or a number is ever performed.

perlfunc man page:

     defined EXPR
     defined
         Returns a Boolean value telling whether EXPR has a value other than the
         undefined value "undef". If EXPR is not present, $_ is checked.

         Many operations return "undef" to indicate failure, end of file, system
         error, uninitialized variable, and other exceptional conditions. This
         function allows you to distinguish "undef" from other values. (A simple
         Boolean test will not distinguish among "undef", zero, the empty string,
         and "0", which are all equally false.) Note that since "undef" is a
         valid scalar, its presence doesn't *necessarily* indicate an exceptional
         condition: "pop" returns "undef" when its argument is an empty array,
         *or* when the element to return happens to be "undef".

     (fcntl)
	...
         You don't have to check for "defined" on the return from "fcntl". Like
         "ioctl", it maps a 0 return from the system call into "0 but true" in
         Perl. This string is true in boolean context and 0 in numeric context.
         It is also exempt from the normal -w warnings on improper numeric
         conversions.

perlglossary man page:

     Boolean
         A value that is either "true" or "false".

     Boolean context
         A special kind of "scalar context" used in conditionals to decide
         whether the "scalar value" returned by an expression is "true" or
         "false". Does not evaluate as either a string or a number. See
         "context".



------------------------------

Date: Mon, 16 Sep 2013 17:26:28 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Return values of boolean operators
Message-Id: <l17f04$kf3$1@reader1.panix.com>

In article <87ob7tb5hw.fsf@vps1.hacking.dk>,
Peter Makholm  <peter@makholm.net> wrote:
>tmcd@panix.com (Tim McDaniel) writes:
>
>> OK, which man page is it that has documentation of the return values
>> of boolean operators?  1 and '', but I dimly recall that there's
>> something special about the particular '' returned for false, that it
>> avoids ... um, some kind of warning if ... something ...
>
>See the perlop man page under the heading "Relational Operators".

I'm afraid that's not so in the Perl 5.14.2 installation.  That
section has only

   Relational Operators
       Binary "<" returns true if the left argument is numerically
       less than the right argument.

       Binary ">" returns true if the left argument is numerically
       greater than the right argument.

       Binary "<=" returns true if the left argument is numerically
       less than or equal to the right argument.

       Binary ">=" returns true if the left argument is numerically
       greater than or equal to the right argument.

       Binary "lt" returns true if the left argument is stringwise
       less than the right argument.

       Binary "gt" returns true if the left argument is stringwise
       greater than the right argument.

       Binary "le" returns true if the left argument is stringwise
       less than or equal to the right argument.

       Binary "ge" returns true if the left argument is stringwise
       greater than or equal to the right argument.

-- 
Tim McDaniel, tmcd@panix.com


------------------------------

Date: Mon, 16 Sep 2013 17:30:24 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Return values of boolean operators
Message-Id: <l17f7g$kf3$2@reader1.panix.com>

In article <l16j7b$ke7$1@dont-email.me>, $Bill <bill@todbe.com> wrote:
>On 9/15/2013 23:51, Tim McDaniel wrote:
>> OK, which man page is it that has documentation of the return values
>> of boolean operators?  1 and '', but I dimly recall that there's
>> something special about the particular '' returned for false, that it
>> avoids ... um, some kind of warning if ... something ...
>
>perlsyn man page:
>
>   Truth and Falsehood
>     The number 0, the strings '0' and '', the empty list "()", and
>     "undef" are all false in a boolean context. All other values are
>     true. Negation of a true value by "!" or "not" returns a special
>     false value. When evaluated as a string it is treated as '', but
>     as a number, it is treated as 0.

Aha!  That matches the text in "man perlsyn" in Perl 5.14.2.  (Silly
me, thinking that true and false would be documented in perldata or
perlop, and not in the syntax page.)

>perldata man page:
 ...
>perlfunc man page:
 ...
>perlglossary man page:

Useful pointers to info on true and false in Perl, but they don't say
what the operators *return*, jsut what is *accepted* as true/false.

-- 
Tim McDaniel, tmcd@panix.com


------------------------------

Date: Tue, 17 Sep 2013 00:10:02 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Return values of boolean operators
Message-Id: <anfkga-fh22.ln1@anubis.morrow.me.uk>


Quoth Peter Makholm <peter@makholm.net>:
> tmcd@panix.com (Tim McDaniel) writes:
> 
> > OK, which man page is it that has documentation of the return values
> > of boolean operators?  1 and '', but I dimly recall that there's
> > something special about the particular '' returned for false, that it
> > avoids ... um, some kind of warning if ... something ...
> 
> See the perlop man page under the heading "Relational Operators".
> 
> Basically it returns a dualvar, not quite unlike what is returned by
> 
>   Scalar::Util::dualvar(0,"")

Exactly the same, in fact, except for PL_sv_no (the internal name of the
standard 'false' value) being a readonly constant. That means that this

    my $x = \!1;
    $$x = 1;

will fail, whereas a ref to a dualvar can be modified. They are
otherwise identical, as you can see with Devel::Peek.

Ben



------------------------------

Date: Mon, 16 Sep 2013 16:56:55 -0700
From: "$Bill" <news@todbe.com>
Subject: Re: Return values of boolean operators
Message-Id: <l185s4$lng$1@news.albasani.net>

On 9/16/2013 10:30, Tim McDaniel wrote:
> Aha! That matches the text in "man perlsyn" in Perl 5.14.2. (Silly me, thinking that true and false would be documented in perldata or perlop, and not in the syntax page.)
It's easier to find stuff if you combine all the man pages into a single text doc
and use Vim (or your favorite editor) to search for what you're looking for.

I'll include my 10 year old version here since it's < 200 lines - may need some
updating  - hope that doesn't bother anyone.  To search for a
function (sysread for eg) in the output file using Vim I
just use
     /^    sysread
since they're always 4 columns in in the output file.

#!perl -sw --

use strict;
use Config;
use Pod::Text;
use Data::Dumper; $Data::Dumper::Indent=1; $Data::Dumper::Sortkeys=1;

# copyright 2001 $Bill Luebkert - you may use/modify freely
#
# make perl manual from pods into single text file
# Usage: perl perlman.pl >perl.man (or perlman.txt or whatever)
#
# Ignore any errors you may get from pod2text conversion module
#

$| = 1;

use vars qw($h $help $s $d);

my $pod_dir = "$Config{archlib}/pod";    # directory where core pod files are
$pod_dir = "$Config{archlibexp}/pods" if $] > 5.008;

my @extra_pods = ();        # other pod file dirs to check - add your own
# push @extra_pods, "$Config{sitelib}/pod" if $] <= 5.008;
# push @extra_pods, "$Config{archlibexp}/pods" if $] > 5.008;

print <<EOD and exit 0 if $h or $help;

Combines all of the Perl man pages into a single file for searching
and reference.  Should generate a lot of format errors.

Usage: $0 [-s] [<pod-dir>] [>perl.man]
     -s        silent (no progress lines)
     pod-dir        optional directory in which to find pod files

EOD

# core sections and ones to skip
my @sections = ();    # built automatically in main if empty (section order)
my %sections = ();    # built automatically in main if empty (section hdrs)
my %do_not_want = ();    # Ones I don't want in my manual

# get core sections (not language or platform specific)
get_sections () if not @sections;

# add windows specific section
push @sections, 'perlwin32';
$sections{'perlwin32'} = 'Perl notes for Windows';

main ();

exit 0;

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub main {

my %pods;

opendir DIR, $pod_dir or die "Error on opendir $pod_dir: $!\n";
while (defined ($_ = readdir DIR)) {
     next if !/\.pod$/;
     s/\.pod$//i;
     $pods{$_} = 1;
}
closedir DIR;

# get the core sections in order

foreach (@sections) {

     my $section = $_;
     my $sect_hdr = $sections{$section};

     if (exists $do_not_want{$section}) {
         print STDERR "Skipping $section Section\n" if !$s;
         next;
     }
     print STDERR "Doing $section '$sect_hdr'\n" if !$s;

     if (not exists $pods{$section}) {
         print STDERR "$section section missing\n";
         next;
     }

     printf "\n%-20.20s  %s\n\n", $section, $sect_hdr;
     pod2text ("-80", "$pod_dir/$section.pod");
     delete $pods{$section};
}

if (0) {    # commented out for now

# handle any extra sections found that weren't in my list

print STDERR "Doing extra section\n" if !$s;
foreach (sort keys %pods) {

     if (exists $do_not_want{$_}) {
         print STDERR "Skipping $_ Section\n" if !$s;
         next;
     }
     print STDERR "Doing $_ Section\n" if !$s;
     print "$_ Section\n\n";
     pod2text ("-80", "$pod_dir/$_.pod");
}

# handle any extra directories of pods

print STDERR "Doing extra directories requested\n" if !$s;
foreach my $dir (@extra_pods) {

     opendir DIR, $dir or die "Error on opendir $dir: $!\n";
     while (defined ($_ = readdir DIR)) {

         next if !/\.pod/;
         s/\.pod$//io;
         if (exists $do_not_want{$_}) {
             print STDERR "Skipping $_ $dir\n" if !$s;
             next;
         }
         print STDERR "Doing $_ extra section\n" if !$s;
         print "$_ section\n\n";
         pod2text ("-80", "$dir/$_.pod");
     }
     closedir DIR;
}

} # if 0

}

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub get_sections {

open IN, "$pod_dir/perl.pod" or die "open $pod_dir/perl.pod: $! ($^E)";
my $lines;
{ undef $/; $lines = <IN>; }
close IN;

$lines =~ s/^.*?=head2 Overview>*?\n//is;
$lines =~ s/\s*=head2 Language-Specific.*$//is;
print (Data::Dumper->Dump([$lines], [qw($lines)])) if $d;
foreach (split /\n/, $lines) {
     next if /^\s*$/;
     next if /^\s*=head2/;
     my @F = split ' ', $_, 2;
     push @sections, $F[0];
     $sections{$F[0]} = $F[1];
}
print (Data::Dumper->Dump([\@sections], [qw(@sections)])) if $d;
print (Data::Dumper->Dump([\%sections], [qw(%sections)])) if $d;

}

__END__




------------------------------

Date: Mon, 16 Sep 2013 18:42:35 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: The old-fashioned guestbook
Message-Id: <l17cdr$4u7$1@news.albasani.net>

I'm looking for a guestbook application, ideally in Perl, free or at a cost.

I don't need a huge framework that happens to include guestbook 
functionality. Instead, I prefer a stand-alone, tried and tested, secure 
and simple low-calorie application that runs on Unix.

Since the guestbook is one of the early website applications that came into 
existence, there must be many good as well as bad off-the-shelf programs.

Any specific recommendations based on experience would be greatly 
appreciated.

Many thanks,
Tuxedo 


------------------------------

Date: Mon, 16 Sep 2013 14:50:12 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: The old-fashioned guestbook
Message-Id: <l17qu9$27d$1@dont-email.me>

On 9/16/2013 10:42 AM, Tuxedo wrote:
> I'm looking for a guestbook application, ideally in Perl, free or at
> a cost.


Are the NMS scripts still considered secure? According to the site, the
last update to the guestbook script was made Feb 2006.



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4035
***************************************


home help back first fref pref prev next nref lref last post