[30861] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2106 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 9 06:09:50 2009

Date: Fri, 9 Jan 2009 03:09:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 9 Jan 2009     Volume: 11 Number: 2106

Today's topics:
        Circular lists <gamo@telecable.es>
    Re: I am needing a gentle introduction to accessing a p <tadmc@seesig.invalid>
    Re: I am needing a gentle introduction to accessing a p <jimsgibson@gmail.com>
    Re: I am needing a gentle introduction to accessing a p <tim@burlyhost.com>
    Re: loops in perl automated ftp <clauskick@hotmail.com>
    Re: mail address validation <stoupa@practisoft.cz>
        new CPAN modules on Fri Jan  9 2009 (Randal Schwartz)
    Re: please help me to understand this code? xhoster@gmail.com
        Pod 2 html formatter that will run online? <usenet@larseighner.com>
    Re: Pod 2 html formatter that will run online? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Pod 2 html formatter that will run online? <usenet@larseighner.com>
    Re: Pod 2 html formatter that will run online? <whynot@pozharski.name>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 9 Jan 2009 11:45:31 +0100
From: gamo <gamo@telecable.es>
Subject: Circular lists
Message-Id: <alpine.LNX.2.00.0901091123380.580@jvz.es>


I want to learn an effient way of handle circular lists.

EXAMPLE:

I have a set of @set = qw(a a b b b c c c c);

In a loop...

@list = shuffle(@set);

and I want to know how many diferent circular lists could be generated.

Thanks, best regards 



PS: The way I handle this is doing  
 
$s = join '',@list;
$string = $s . $s;

and after that comparing $s with all the previous stored substr 
$string,$i,9 for $i (0..9)   

BUT this way is very inefficient for a large @set or long loop.


-- 
http://www.telecable.es/personales/gamo/
"Was it a car or a cat I saw?"
perl -E 'say 111_111_111**2;'


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

Date: Thu, 8 Jan 2009 15:56:29 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: I am needing a gentle introduction to accessing a perl array from a  reference
Message-Id: <slrngmctkd.aqm.tadmc@tadmc30.sbcglobal.net>

Larry W. Virden <lvirden@gmail.com> wrote:
> I have some legacy code, the author of whom is no longer available for
> consultation.
>
> Here is a piece of the code in question:


Is the code copy/pasted, or re-typed?


> up here, the DBI connection to the database, the select statement,
> etc. occurs
>:
>
> # put results of query into single array and return
>   while (@next_row= $query->fetchrow_array()){
>
>     push(@array_result,@next_row);
>   }
>
>   $query->finish;
>   $dbconn->disconnect();
>   return \@array_result;


That is an awfully strange way to do it, unless your query is selecting
only a single column.

Is this your real code?

The data structure here is nothing more than (a reference to) a flat array.


> I am trying to figure out a readable approach to
> dealing with the value that is returned.


To help you with that, we will need rather precise information on what
that structure is...


> One piece of code that I've bubble-gummed and bailing wired together
> basically does this:
>
> $super_list = thefunction($argument);
> my $tot = scalar(@$super_list);
> if ( $tot_supers >= 1 ) {
>         for (my $staff=0; $staff < $tot_supers; $staff++ ) {


The Perlish way would be to replace the 3 lines above with:

   if ( @$super_list ) {
       foreach my $staff ( 0 .. $#$super_list ) {

I'm guessing you would benefit by spending some quality time with:

   perldoc perlreftut

and

   perldoc Data::Dumper


>                 if ( defined( $super_list->[$staff]{'User_Name'} ) ) {
                                                     ^           ^
                                                     ^           ^
Eh? Where did the hash come from?

There is no hash anywhere in your code up at the top...


>                        $super_login = $super_list->[$staff]
> {'User_Name'};
>                        chomp($super_login);
>                        print $super_login . "\n" ;
>                 } else {
>                         print "Unable to identify user $staff \n";
>                 }
>         }
>     }
>
> The main concern I have here is that if I want to write a "print all
> columns of data" type routine, I would have to hand code a series of
> if (defined...) type statements, differing depending on what table is
> being dumped.
>
> Is there another approach that would allow me to dynamically generate
> the columns from the hash and then loop through them?


    perldoc -f keys

        Returns a list consisting of all the keys of the named hash.


> I apologize from the vague description - I'm still working on
> understanding the data structure , etc.


We need an understanding of the (actual) data structure if we are
to help you suss out how to access it.

Try posting a bit of output from:

   use Data::Dumper;
   print Dumper $super_list;


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Thu, 08 Jan 2009 13:11:12 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: I am needing a gentle introduction to accessing a perl array from a reference
Message-Id: <080120091311123160%jimsgibson@gmail.com>

In article
<5ac3764f-75b2-4a7d-96ed-6e36e22484c9@a12g2000pro.googlegroups.com>,
Larry W. Virden <lvirden@gmail.com> wrote:

> I have some legacy code, the author of whom is no longer available for
> consultation.
> 
> Here is a piece of the code in question:
> 
> :
> up here, the DBI connection to the database, the select statement,
> etc. occurs
> :
> 
> # put results of query into single array and return
>   while (@next_row= $query->fetchrow_array()){
> 
>     push(@array_result,@next_row);
>   }

Are you sure this is your code? The above statements will have the
unfortunate effect of concatenating all of the rows returned into a
single array. Perhaps this is what you actually have:
   while ( my @next_row= $query->fetchrow_array()){
 
     push(@array_result,\@next_row);
   }

Notice the difference. This loop will produce an array of references to
arrays, one for each row. This is called an "array-of-arrays".

> 
>   $query->finish;
>   $dbconn->disconnect();
>   return \@array_result;
> 
> I am a perl novice. I am trying to figure out a readable approach to
> dealing with the value that is returned.
> 
> One piece of code that I've bubble-gummed and bailing wired together
> basically does this:
> 
> $super_list = thefunction($argument);

What is the relationship between thefuncion() and the code you have
shown above?

> my $tot = scalar(@$super_list);
> 
> if ( $tot_supers >= 1 ) {

What is the value of $tot_supers? Do you mean $tot?

>         for (my $staff=0; $staff < $tot_supers; $staff++ ) {
>                 if ( defined( $super_list->[$staff]{'User_Name'} ) ) {

Where did the hash %{$super_list->[$staff]} come from?

>                        $super_login = $super_list->[$staff]
> {'User_Name'};
>                        chomp($super_login);
>                        print $super_login . "\n" ;
>                 } else {
>                         print "Unable to identify user $staff \n";
>                 }
>         }
>     }
> 
> The main concern I have here is that if I want to write a "print all
> columns of data" type routine, I would have to hand code a series of
> if (defined...) type statements, differing depending on what table is
> being dumped.

Why? Why not use the elements that went into the select statement that
generated the returned data? You should know what you have asked for.

> 
> Is there another approach that would allow me to dynamically generate
> the columns from the hash and then loop through them?
> 
> I apologize from the vague description - I'm still working on
> understanding the data structure , etc.

Please explain in more detail your data structures so that we may
understand them. Your descriptions are incomplete.

-- 
Jim Gibson


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

Date: Thu, 08 Jan 2009 14:25:56 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: I am needing a gentle introduction to accessing a perl array from a reference
Message-Id: <U3v9l.3$Z4.1@newsfe13.iad>

Larry W. Virden wrote:

> I have some legacy code, the author of whom is no longer available for
> consultation.
> 
> Here is a piece of the code in question:
> 
> :
> up here, the DBI connection to the database, the select statement,
> etc. occurs

Can you either post the fully relevant portions of your code, or
elaborate on some aspects?  Some parts of the code you've posted don't
seem to relate to the other, so either relevant code is missing, or...?
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Fri, 9 Jan 2009 02:25:28 -0800 (PST)
From: Snorik <clauskick@hotmail.com>
Subject: Re: loops in perl automated ftp
Message-Id: <58c596f9-dcf9-4b6a-8fc0-011bc6022fe4@n33g2000pri.googlegroups.com>

On 8 Jan., 15:22, Tad J McClellan <ta...@seesig.invalid> wrote:
> ["Followup-To:" header set to comp.lang.perl.misc.]
>
>
>
> Snorik <clausk...@hotmail.com> wrote:
> > On 8 Jan., 11:25, "banzai" <ban...@ll.com> wrote:
> >> Need help with the following automated ftp script please;
>
> >> if (defined ($ftp1)) {
> >>     $ftp1->login($FTP1user,$FTP1password) or LogError("FTP login to
> >> $FTP1server failed");
> >>     if (defined $FTP1destination){
> >>         $ftp1->cwd($FTP1destination) or LogError("Could not change directory
> >> to $FTP1destination on $FTP1server");
> >>     }
> >>     $ftp1->binary;
> >>     $ftp1->put("$FileBodyName.tar.gz") or LogError("Could not FTP copy
> >> $FileBodyName.tar.gz to $FTP1server");
> >>     $ftp1->put("$DataTagName.gz") or LogError("Could not FTP copy
> >> $DataTagName.gz to $FTP1server");
> >>     $ftp1->quit;} else {
>
> >>         LogError("FTP open failed to $FTP1server, error code: $!");}
>
> >> #
>
> >> I need to modify the above so that the ftp transfers (put's) are attempted
> >> up to 5 times in case the remote server does not respond. No time delay
>
>                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> >> needed between retries.
>
> >> TIA
>
> > Why not simply use a counter variable in a while loop?
>
> Because if the remote server _does_ respond, it will upload the
> same file 5 times when once was enough.
>
> The solution must somewhere include a test of whether the server
> responded or not.

You are right, as said elsethread, I did not think of that at all.

> > my $count = 0;
> > while ($count <= 4)
>
> That is an error-prone way to do it.
>
>     foreach my $count ( 0 .. 4 )
> or
>     foreach my $count ( 1 .. 5 )
>
> is much easier to read (and therefore, easier to get right).

Yes, indeed, thanks for pointing that out, I had completely forgotten
about this possibility.


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

Date: Fri, 9 Jan 2009 01:13:18 +0100
From: "Petr Vileta \"fidokomik\"" <stoupa@practisoft.cz>
Subject: Re: mail address validation
Message-Id: <gk6521$290g$1@ns.felk.cvut.cz>

~greg wrote:
> "Petr Vileta "fidokomik"" > >
>>> http://community.opensourcedotnet.info/blogs/computer/archive/2006/09/16/Email-Address-Format-Myths.aspx
>>
>> Thanks a lot. This is exactly what I need.
>> --
>
> probably you should try to stay off his "plus-haters list of shame".
> :)
>
> ~greg

Hi greg
I need this mail validation for webform only, not for my MTA. I do validation 
with

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.!#$%&"*+-/=?^_`{|}~

in left part and

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-

in domain part. In addition to this I check if mail address end with DOT + 
minimally 2 characters, so
user@example.c - invalid
user@example.cz - valid

I do this validation because many users make typing errors, webform try to send 
message for these nonsensical addressess (every 4 hours again for 4 days) and my 
MTA gasp :-)
-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



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

Date: Fri, 9 Jan 2009 05:42:26 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Jan  9 2009
Message-Id: <KD6vuq.v7x@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

BerkeleyDB-Manager-0.11
http://search.cpan.org/~nuffin/BerkeleyDB-Manager-0.11/
General purpose BerkeleyDB wrapper 
----
Catalyst-Plugin-Authentication-0.10009_01
http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10009_01/
Infrastructure plugin for the Catalyst authentication framework. 
----
Catalyst-Plugin-Session-0.19_01
http://search.cpan.org/~bobtfish/Catalyst-Plugin-Session-0.19_01/
Generic Session plugin - ties together server side storage and client side state required to maintain session data. 
----
CatalystX-Imports-0.04
http://search.cpan.org/~flora/CatalystX-Imports-0.04/
Shortcut functions for Catalyst controllers 
----
Cluster-Similarity-v0.01
http://search.cpan.org/~ingrif/Cluster-Similarity-v0.01/
compute the similarity of two classifications. 
----
Config-INI-Access-0.9999
http://search.cpan.org/~andy/Config-INI-Access-0.9999/
Syntactic sugar for accessing data from .ini-files 
----
Crypt-SKey-0.10
http://search.cpan.org/~kwilliams/Crypt-SKey-0.10/
Perl S/Key calculator 
----
DBIx-Easy-0.18
http://search.cpan.org/~hornburg/DBIx-Easy-0.18/
Easy to Use DBI interface 
----
Dansguardian-0.2
http://search.cpan.org/~mogaal/Dansguardian-0.2/
Simple module for administer dansguardian's control files. 
----
Dansguardian-0.3
http://search.cpan.org/~mogaal/Dansguardian-0.3/
Simple module for administer dansguardian's control files. 
----
Darcs-Inventory-1.0.2
http://search.cpan.org/~david/Darcs-Inventory-1.0.2/
Read and parse a darcs version 1 or 2 inventory file 
----
DateTime-Format-Natural-0.74_01
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.74_01/
Create machine readable date/time with natural parsing logic 
----
Devel-PerlySense-0.0177
http://search.cpan.org/~johanl/Devel-PerlySense-0.0177/
Perl IDE backend with Emacs frontend 
----
Devel-REPL-1.003001
http://search.cpan.org/~mstrout/Devel-REPL-1.003001/
a modern perl interactive shell 
----
Directory-Transactional-0.05
http://search.cpan.org/~nuffin/Directory-Transactional-0.05/
----
EAFDSS-0.12
http://search.cpan.org/~hasiotis/EAFDSS-0.12/
Electronic Fiscal Signature Devices Library 
----
File-Cache-Persistent-0.1
http://search.cpan.org/~andy/File-Cache-Persistent-0.1/
Caches file content and allows to use it even after file is deleted 
----
File-Cache-Persistent-0.2
http://search.cpan.org/~andy/File-Cache-Persistent-0.2/
Caches file content and allows to use it even after file is deleted 
----
Graphics-Color-0.18
http://search.cpan.org/~gphat/Graphics-Color-0.18/
Device and library agnostic color spaces. 
----
HTML-GoogleMaps-10
http://search.cpan.org/~nmueller/HTML-GoogleMaps-10/
a simple wrapper around the Google Maps API 
----
IO-Lambda-1.01
http://search.cpan.org/~karasik/IO-Lambda-1.01/
non-blocking I/O as lambda calculus 
----
Inline-Wrapper-0.04
http://search.cpan.org/~infidel/Inline-Wrapper-0.04/
Convenient module wrapper/loader routines for Inline.pm 
----
Mail-Address-MobileJp-0.09
http://search.cpan.org/~miyagawa/Mail-Address-MobileJp-0.09/
mobile email address in Japan 
----
Megagram-ResolveSRV-0.01
http://search.cpan.org/~wilsond/Megagram-ResolveSRV-0.01/
----
MiniPAN-0.02
http://search.cpan.org/~lev/MiniPAN-0.02/
A minimalistic installer of CPAN modules for the iPhone 
----
MiniPAN-0.03
http://search.cpan.org/~lev/MiniPAN-0.03/
A minimalistic installer of CPAN modules for the iPhone 
----
Net-Autoconfig-1.11
http://search.cpan.org/~kevin/Net-Autoconfig-1.11/
Perl extension for provisioning or reconfiguring network devices. 
----
Net-FTPSSL-0.05
http://search.cpan.org/~cleach/Net-FTPSSL-0.05/
A FTP over SSL/TLS class 
----
Net-NationalRail-LiveDepartureBoards-0.01
http://search.cpan.org/~diocles/Net-NationalRail-LiveDepartureBoards-0.01/
Live Departure Boards information 
----
Net-OpenSSH-0.13
http://search.cpan.org/~salva/Net-OpenSSH-0.13/
Perl SSH client package implemented on top of OpenSSH 
----
Net-OpenSSH-0.14
http://search.cpan.org/~salva/Net-OpenSSH-0.14/
Perl SSH client package implemented on top of OpenSSH 
----
POE-Component-Client-opentick-0.21
http://search.cpan.org/~infidel/POE-Component-Client-opentick-0.21/
A POE component for working with opentick.com's market data feeds. 
----
RTx-RT34-Bulk-CF-Edit-0.002
http://search.cpan.org/~alexmv/RTx-RT34-Bulk-CF-Edit-0.002/
Allow bulk editing of custom fields 
----
Scalar-Andand-0.01
http://search.cpan.org/~leont/Scalar-Andand-0.01/
Guarded method invocation. 
----
Scalar-Andand-0.02
http://search.cpan.org/~leont/Scalar-Andand-0.02/
Guarded method invocation. 
----
Scalar-Andand-0.03
http://search.cpan.org/~leont/Scalar-Andand-0.03/
Guarded method invocation. 
----
Storable-AMF-0.40
http://search.cpan.org/~grian/Storable-AMF-0.40/
Perl extension for serialize/deserialize AMF0/AMF3 data 
----
Sys-Mmap-Simple-0.03_5
http://search.cpan.org/~leont/Sys-Mmap-Simple-0.03_5/
Memory mapping made simple and safe. 
----
TAP-Formatter-JUnit-0.01
http://search.cpan.org/~gtermars/TAP-Formatter-JUnit-0.01/
Harness output delegate for JUnit output 
----
Text-Editor-Easy-0.44
http://search.cpan.org/~grommier/Text-Editor-Easy-0.44/
A perl module to edit perl code with syntax highlighting and more. 
----
Text-Snippet-0.01
http://search.cpan.org/~bphillips/Text-Snippet-0.01/
TextMate-like snippet functionality 
----
Text-Snippet-0.02
http://search.cpan.org/~bphillips/Text-Snippet-0.02/
TextMate-like snippet functionality 
----
UMLS-Interface-0.01
http://search.cpan.org/~btmcinnes/UMLS-Interface-0.01/
Perl interface to the Unified Medical Language System 
----
UltraDNS-0.01_01
http://search.cpan.org/~timb/UltraDNS-0.01_01/
Client API for the NeuStar UltraDNS Transaction Protocol 
----
WWW-Mixi-Scraper-0.22
http://search.cpan.org/~ishigaki/WWW-Mixi-Scraper-0.22/
yet another mixi scraper 
----
WebService-Buxfer-0.01
http://search.cpan.org/~nheinric/WebService-Buxfer-0.01/
Interact with the Buxfer webservice 
----
libapreq-1.34
http://search.cpan.org/~isaac/libapreq-1.34/
Apache Request C Library 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: 08 Jan 2009 22:36:19 GMT
From: xhoster@gmail.com
Subject: Re: please help me to understand this code?
Message-Id: <20090108173818.215$QS@newsreader.com>

Pilcrow <pilcrow6@gmail.com> wrote:

> The following is part of faq 4.51.  I am afraid that a good deal of it
> is beyond my understanding, and, I suspect, beyond the understaning of a
> good many others who read clpm.  It works, but I don't know how. Perhaps
> some genius will explain it, line by line, to me and the other dummies.

I will explain the parts peculiar to Perl.


> Perhaps someone will also tell me the source for "The Fischer-Krause
> Algorithm", since TAOCP, vol 4 is still unpublished?

I'm surprised there isn't a wikipedia entry, but there doesn't seem to
be one.  Hunh.  It is quite subtle, and I can't explain other than to say
"Just follow the pointer math"

>             #!/usr/bin/perl -n
>             # Fischer-Krause ordered permutation generator
>
>             sub permute (&@) {

Takes a code block/anonymous subroutine reference and a list.

>                     my $code = shift;
>                     my @idx = 0..$#_;
>                     while ( $code->(@_[@idx]) ) {

Executes the code block on each permutation of the list.  If the
code block ever returns false, then it aborts the permutations early
(your code block should not return false, as printing to STDOUT rarely
fails. so you probably don't take advantage of this feature).  This could
also be written something like:

                      while ( 1 ) {
                              return unless $code->(@_[@idx]);

>                             my $p = $#idx;
>                             --$p while $idx[$p-1] > $idx[$p];

Subtle code that implements Fischer-Krause, not peculiar to Perl.

>                             my $q = $p or return;

If $p is zero, then you have finished all permutations.  "return"
terminates the execution of this subroutine at that point.

>                             push @idx, reverse splice @idx, $p;

reverses the part of @idx from $p on.  I think it might be better written
as:

         @idx[$p..$#idx]=reverse @idx[$p..$#idx];

>                             ++$q while $idx[$p-1] > $idx[$q];
>                             @idx[$p-1,$q]=@idx[$q,$p-1];

More subtle code that implements Fischer-Krause, not peculiar to Perl.
(The last line swaps the elements of @idx at $p-1 and $q).

>                     }
>             }


>
>             permute { print "@_\n" } split;

{ print "@_\n" } is the code block that gets executed for each permutation.
If you wanted to do something other than printing the permutations, you
would use a different block here.

split with no arguments splits the contents of $_ on whitespace, stripping
leading and trailing empty strings.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Thu, 8 Jan 2009 23:28:29 +0000 (UTC)
From: Lars Eighner <usenet@larseighner.com>
Subject: Pod 2 html formatter that will run online?
Message-Id: <slrngmd2vm.10k2.usenet@debranded.larseighner.com>

Does anyone know of a Pod to HTML formatter that will run *online*?

-- 
        Lars Eighner <http://larseighner.com/> usenet@larseighner.com
    Bush's third term begins Jan. 20th with an invocation by Rick Warren.
                Obama: No hope; No change; More of the Same.


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

Date: Thu, 8 Jan 2009 22:35:14 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Pod 2 html formatter that will run online?
Message-Id: <3q7j36xs3h.ln2@goaway.wombat.san-francisco.ca.us>

On 2009-01-08, Lars Eighner <usenet@larseighner.com> wrote:
> Does anyone know of a Pod to HTML formatter that will run *online*?

How about pod2html?  (minimally tested)

#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $cgi=CGI->new;
print $cgi->header;
# if your perl sets -T when run under a webserver
$ENV{PATH}='';

print `/usr/bin/pod2html /usr/lib/perl5/5.8.4/Pod/Text.pm`;


--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Fri, 9 Jan 2009 08:58:52 +0000 (UTC)
From: Lars Eighner <usenet@larseighner.com>
Subject: Re: Pod 2 html formatter that will run online?
Message-Id: <slrngme4d4.135v.usenet@debranded.larseighner.com>

In our last episode, <3q7j36xs3h.ln2@goaway.wombat.san-francisco.ca.us>, the
lovely and talented Keith Keller broadcast on comp.lang.perl.misc:

> On 2009-01-08, Lars Eighner <usenet@larseighner.com> wrote:
>> Does anyone know of a Pod to HTML formatter that will run *online*?

> How about pod2html?  (minimally tested)

> #!/usr/bin/perl
> use strict;
> use warnings;
> use CGI;
> my $cgi=CGI->new;
> print $cgi->header;
> # if your perl sets -T when run under a webserver
> $ENV{PATH}='';

> print `/usr/bin/pod2html /usr/lib/perl5/5.8.4/Pod/Text.pm`;

In addition to the above, pod2html seems to require a scratch file,
so you have to change to a world readable and writeable directory, as it
runs as nobody.

As I am working in PHP, this works where tmp is a world writeable, world
readable directory below the current one.

<?php

$old = getenv('PATH');
echo '<p>',$old,' oldpath</p>';
putenv("PATH=''");
$ocwd = getcwd();
echo '<p>',$ocwd,' old current working directory</p>',
chdir('tmp');
$foo = 
`/usr/local/bin/pod2html /usr/local/lib/perl5/5.8.8/pod/perldoc.pod`;
$foo = htmlspecialchars($foo);
putenv('PATH='.$old);
$foo = htmlspecialchars($foo);
echo '<p>',$foo,'<p>'; 
echo '<p>',getenv('PATH'),' restored path</p>';
chdir($ocwd);
echo '<p>',getcwd(),' restored current working directory</p>';

?>


-- 
        Lars Eighner <http://larseighner.com/> usenet@larseighner.com
    Bush's third term begins Jan. 20th with an invocation by Rick Warren.
                Obama: No hope; No change; More of the Same.


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

Date: Fri, 09 Jan 2009 10:10:42 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Pod 2 html formatter that will run online?
Message-Id: <slrngme1ks.t7m.whynot@orphan.zombinet>

On 2009-01-08, Lars Eighner <usenet@larseighner.com> wrote:
> Does anyone know of a Pod to HTML formatter that will run *online*?

You've meant this?

	pod2html precious.pod | elinks -force-html

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

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:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#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 2106
***************************************


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