[18115] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 275 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 12 18:06:33 2001

Date: Mon, 12 Feb 2001 15:05:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982019120-v10-i275@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Feb 2001     Volume: 10 Number: 275

Today's topics:
    Re: .htaccess authentification <godzilla@stomp.stomp.tokyo>
    Re: Accessing-deleting mail from perl <mischief@velma.motion.net>
    Re: capturing diagnostics <abe@ztreet.demon.nl>
    Re: Directory listings in a table <mothra@nowhereatall.com>
    Re: directory structure (Ben Okopnik)
    Re: flock() strategy for Win95? - eval() etc <godzilla@stomp.stomp.tokyo>
    Re: flock() strategy for Win95? - eval() etc <mkruse@netexpress.net>
    Re: flock() strategy for Win95? - eval() etc <godzilla@stomp.stomp.tokyo>
        how to find the version of perl? <shino_korah@yahoo.com>
    Re: how to find the version of perl? <jdb@ga.prestige.net>
    Re: how to find the version of perl? <henroc@mindspring.com>
    Re: Installation Problems with Perl 5.6 on NCR Box (Andy Dougherty)
        Looking for alternative to Google (was deja) newsgroup  <harriso2@pilot.msu.edu>
    Re: Looking for alternative to Google (was deja) newsgr <joe+usenet@sunstarsys.com>
    Re: LWP debug (Charles DeRykus)
        Need help with an array <jgs2283@MailAndNews.com>
    Re: Need help with an array egwong@netcom.com
    Re: Need help with an array (Mark Jason Dominus)
        newbie problem installing "subscribe me" mailing list <philw@hotpop.com>
        Perl and Linux Package Managers (rpm/deb) <jfeuerst@eecs.tufts.edu>
    Re: Perl and Linux Package Managers (rpm/deb) egwong@netcom.com
    Re: Perl and Linux Package Managers (rpm/deb) <jfeuerst@eecs.tufts.edu>
    Re: Perl and Linux Package Managers (rpm/deb) egwong@netcom.com
    Re: Perl DBI -  Can't call method "prepare" on an undef <jhalbrook@bjcmail.carenet.org>
        Perl FAQ: Stripping blank space <jeffno@denali.ccs.neu.edu>
    Re: Perl FAQ: Stripping blank space <joe+usenet@sunstarsys.com>
    Re: postgres perl problem <peter.sundstrom-eds@eds.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Feb 2001 13:47:46 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: .htaccess authentification
Message-Id: <3A885A02.9CAC1811@stomp.stomp.tokyo>

"Jason Q." wrote:

> In a perl/cgi script, how (if possible) do I emulate
> .htaccess authentification (username/password).


Below my signature you will find one of two
methods to simulate logon and password style
authentication. This method relies on a read
and parse routine receiving input data from
a 'post' form action.

This script is ready to run. Load it to your
server and point your browser to its URL. The
name of this script must be "test1.cgi" for
your URL path. Remember to change my first
line Perl locale as needed for your server.

My test script relies on a 'bucket brigade'
method of passing a logon and password via
hidden fields, to a new cgi generated page
which also has a post form action.

You may also use a read and parse routine
which employs a read of a Query String
which includes a logon and password.
This type of read and parse deals with
a GET function and requires no form button.
However, this causes a complication; your
first page must include a 'post action'
form to grab your logon and password
initially. After this, you may create
a URL with a Query String as needed 
with a cgi script. This URL and all
subsequent URL, will also need to 
'bucket brigade' your information much
like a post action, but using a GET
method via a Query String.

An example of a Query String, after grabbing
your logon and password with a Post action,
for your next cgi generated page would be:

print "Location: http..your/cgi/page.cgi?Logon=Godzilla&Password=Rocks";

Research and learn about Post actions, Get actions
and Read / Parse routines. Ample documentation is
available on our internet. You would be wise to
research a module, CGI.pm , which can handle these
type of devices for you, with greater ease for
beginning Perl programmers.

A critical point is, your first page must be a
form action to provide user input for a logon
and a password. Subsequent pages must be cgi
scripts using POST or GET methods. If you break
this chain of events by linking to a standard
html page, you lose your authentication ability.


Godzilla!
--

Note, @Password represents your logon/passwords
within a script, or could be a 'file open' call
to read in logon/passwords from an external source.

TEST SCRIPT:
____________


#!perl

print "Content-type: text/html\n\n",
      "<HTML><BODY>\n<BR><BR><BR><BR>\n";

&Read_Parse;

sub Read_Parse
 {
  if ($ENV{'CONTENT_LENGTH'} > 131072)
   { print "<BR><BR><H1>Oh, You Are A Cute One!</H1></BODY></HTML>"; exit; }
  else
   {
    local (*in) = @_ if @_;
    local ($i, $key, $value);
    read (STDIN,$in,$ENV{'CONTENT_LENGTH'});
    @in = split (/&/,$in);
    foreach $i (0 .. $#in)
     {
      $in[$i] =~ s/\+/ /g;
      ($key, $value) = split (/=/,$in[$i],2);
      ($value eq "") && next;
      $key =~ s/%(..)/pack ("c",hex($1))/ge;
      $value =~ s/%(..)/pack ("c",hex($1))/ge;
      $value =~ s/<\s+/</gi;
      $value =~ s/\(/&#40;/g;
      $value =~ s/\)/&#41;/g;
      $value =~ s/\*/&#42;/g;
      $value =~ s/\[/&#91;/g;
      $value =~ s/\\/&#92;/g;
      $value =~ s/\]/&#93;/g;
      $value =~ s/\^/&#94;/g;
      $value =~ s/`/&#96;/g;
      $value =~ s/{/&#123;/g;
      $value =~ s/\|/&#124;/g;
      $value =~ s/}/&#125;/g;
      $in{$key} .= "\0" if (defined($in{$key})); 
      $in{$key} .= $value;
     }
    return 1;
   }
 }

if (!($in{Control}))
 {
  print "
     For Testing Purposes:
     <P>
     Logon: Godzilla
     <BR>
     Password: Rocks
     <P>
     Logon: Kira
     <BR>
     Password: Bozo
     <P>
     <FORM ACTION=\"test1.cgi\" METHOD=\"POST\">
     <INPUT TYPE=\"submit\" NAME=\"Button\" VALUE=\"Test Script\">
     <INPUT TYPE=\"hidden\" NAME=\"Control\" VALUE=\"true\">
     <P>
     Logon:
     <BR>
     <INPUT TYPE=\"text\" SIZE=\"8\" NAME=\"Logon\">
     <P>
     Password:
     <BR>
     <INPUT TYPE=\"text\" SIZE=\"8\" NAME=\"Password\">
     </FORM>";
 }
else
 {
  $pass = "false";
  @Password = qw (Godzilla:Rocks Kira:Bozo);
  foreach $element (@Password)
   {
    ($logon, $password) = split (/:/, $element);
    if (($in{Logon} eq $logon) & ($in{Password} eq $password))
     {
      $pass = "true"; 
      &Approved; 
      last;
     }
   }

  if($pass eq "false")
     { &Denied; }
 }

sub Approved
 {
  print "
     <BR><BR>
     Logon And Password Approved.
     <P>
     Look At Document Source And You Will
     <BR>
     Note Both Are Carried As Hidden Fields.
     <P>

     <FORM ACTION=\"test1.cgi\">
     <INPUT TYPE=\"submit\" VALUE=\"Test Again\">
     <INPUT TYPE=\"hidden\" NAME=\"Control\" VALUE=\"\">
     <INPUT TYPE=\"hidden\" NAME=\"Logon\" VALUE=\"$in{Logon}\">
     <INPUT TYPE=\"hidden\" NAME=\"Password\" VALUE=\"$in{Password}\">
     </FORM>";
 }

sub Denied
 {
  print "
     <BR><BR>
     <H1>
     ACCESS DENIED
     <BR>
     INCORRECT LOGON AND PASSWORD
     </H1>
     <P>
 
     <FORM ACTION=\"test1.cgi\">
     <INPUT TYPE=\"submit\" VALUE=\"Test Again\">
     <INPUT TYPE=\"hidden\" NAME=\"Control\" VALUE=\"\">
     </FORM>";
 }

print "\n\n</BODY></HTML>";

exit;


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

Date: Mon, 12 Feb 2001 20:10:49 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Accessing-deleting mail from perl
Message-Id: <t8ggq9sp3e832b@corp.supernews.com>

sparcguy@my-deja.com wrote:
> I am currently in need of assistance in finding the best way to access
> and delete email.  I am currently using mail::internet & mail::util to
> access basic mail info from /var/mail/username but I am currently
> unable to figure out how to delete messages once they have been read.
> I am also unsure if if the above modules are the best one to use to
> access mail from perl.

> Any example code would be appriciated.

There are other mail modules. One of the most handy is Net::POP3
if you are running a POP3 server on the host. It comes with docs,
but not much example code.

Chris

-- 
Christopher E. Stith

Get real!  This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental. -- nobull, clp.misc



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

Date: Mon, 12 Feb 2001 23:55:45 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: capturing diagnostics
Message-Id: <drpg8tkl2tl9bjiieui21nug3dh04r0g4a@4ax.com>

On 10 Feb 2001 10:30:11 -0500, Jonathan Feinberg <jdf@pobox.com> wrote:

> Unfortunately the OP is on a Win32 box.  I have never been able to
> make stream redirection work as advertised using the Win32 command
> prompt.

	perl -wle "print $x" 2>&1 | splain

and

	perl -wle "print $x" 2>&1 | splain > splain.out

Work as expected on my NT box (with CMD.EXE) ... :-)

	perldoc splain

-- 
Good luck,
Abe
perl -le '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona
 tsuJ")'


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

Date: Mon, 12 Feb 2001 12:02:24 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: Directory listings in a table
Message-Id: <3A884150.7D8F7943@nowhereatall.com>

Paul wrote:
> 
> I'm looking for a script that I can use that will display a directory
> contents in a table in order of the file dates.
> 
> Paul
Try something like this.

#!/usr/bin/perl -wT
use strict;
use Date::Format qw(ctime);
use CGI qw(:standard);
my $directory='c:/temp';
my %dir_hash=();
my $file=();
opendir(DIR, "$directory") or die "Can't open $directory: $!\n";
  while (defined ($file = readdir DIR) )   {
    next if $file =~ /^\.\.?$/;  # this skips . and ..
    $dir_hash{$file}=(stat("$directory/$file"))[10];
  }
my $filename=();
print header();
print start_html();
print '<TABLE>';
foreach $filename (sort {$dir_hash{$b} <=> $dir_hash{$a} } keys
%dir_hash )  {
 
    print Tr(td($filename), td(ctime($dir_hash{$filename})));
   
}
print '</TABLE>';
print end_html;

Mothra!


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

Date: 12 Feb 2001 20:22:02 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: directory structure
Message-Id: <slrn98ghmn.jcj.ben-fuzzybear@Odin.Thor>

The ancient archives of 12 Feb 2001 17:28:19 GMT showed
Abigail of comp.lang.perl.misc speaking thus:
>Walter Hafner (hafner-usenet@ze.tu-muenchen.de) wrote on MMDCCXXII
>September MCMXCIII in <URL:news:srj7l2vomn1.fsf@w3projns.ze.tu-muenchen.de>:
>// Hello,
>// 
>// I need to access a squid-like directory structure in round-robin.
>// If I have directories "/aa/" to /zz/, can anyone give me a convenient
>// way to access them? aa, ab, ... zz, aa, ab, ... 
>// 
>// I know how to do it with substrings etc. I just wanted a more elegant
>// solution. :-)
>
>
>    my @foo = ('aa' .. 'zz');
>    my $i   =   0;
>    while (1) {print "/$foo[($i+=1)%=@foo]/\n"}


Yow. Elegant you wanted, elegant you got - and precisely per spec, too. 
Assignment, postincrement, modulo the return scalar from array, even that
(1) as a nice placeholder for whatever loop condition you might want - all
in one shot. OK, call me easily impressed, but that's _cool._ :)


Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Men are like steel. When they lose their temper, they lose their worth."
 -- Chuck Norris


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

Date: Mon, 12 Feb 2001 12:21:09 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: flock() strategy for Win95? - eval() etc
Message-Id: <3A8845B5.28C64B75@stomp.stomp.tokyo>

Matt Kruse wrote:

(snippage)
 
> Godzilla! wrote:

> > > > Traditional file lock is not supported on Win 9.x systems.

> > > I knew this ;)

> > Then why are you trying to use file lock under Win9.x?
> > This is exceptionally illogical.
 
> No, it's not. You're missing the point.

Not at all. Why would you expect return, even with
a workaround, from a flock call under Win9.x when 
flock is not supported?

Incidently, under a webserver running on Win9.x 
the very moment a script encounters a flock call,
this script is terminated; crash and burn.

Suppose the same is true for ActiveState
or straight Perl 5.6 ?

You have said flock doesn't cause errors
on a Win9.x platform.

I have some difficulties with your initial article.


Godzilla!


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

Date: Mon, 12 Feb 2001 15:20:58 -0600
From: "Matt Kruse" <mkruse@netexpress.net>
Subject: Re: flock() strategy for Win95? - eval() etc
Message-Id: <3a885324$0$21434@wodc7nh0.news.uu.net>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Not at all. Why would you expect return, even with
> a workaround, from a flock call under Win9.x when
> flock is not supported?
> Incidently, under a webserver running on Win9.x
> the very moment a script encounters a flock call,
> this script is terminated; crash and burn.

In older versions of ActivePerl, this was the case.
In the current version (5.6) this is not the case.
flock calls are ignored and do not cause fatal errors.

This is the cause of the dilemma which I posted about to begin with.

It is not advised to have such a negative response to something about which
you do not have all the facts.

Matt Kruse
http://www.mattkruse.com/






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

Date: Mon, 12 Feb 2001 14:28:16 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: flock() strategy for Win95? - eval() etc
Message-Id: <3A886380.356AEC34@stomp.stomp.tokyo>

Matt Kruse wrote:
 
> Godzilla! wrote:

> > Not at all. Why would you expect return, even with
> > a workaround, from a flock call under Win9.x when
> > flock is not supported?

> > Incidently, under a webserver running on Win9.x
> > the very moment a script encounters a flock call,
> > this script is terminated; crash and burn.
 
> In older versions of ActivePerl, this was the case.
> In the current version (5.6) this is not the case.
> flock calls are ignored and do not cause fatal errors.
 
> This is the cause of the dilemma which I posted about to begin with.
 
> It is not advised to have such a negative response to something
> about which you do not have all the facts.


My testing of flock under Perl version 5.6.0 using 
Apache 3.14 and my testing of flock under Perl version
5.6.0 using ActiveState Build 623, reflect a reality 
quite contrary to your view of reality.

Godzilla!


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

Date: Mon, 12 Feb 2001 13:28:55 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: how to find the version of perl?
Message-Id: <969kin$seg@news.or.intel.com>

Hi,

   How can i find the which versin of perl i'm using?
I have perl in both NT and LINUX.It was already installed. what is te
command i should use to get the version?

Thanks in advance





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

Date: Mon, 12 Feb 2001 20:35:45 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: Re: how to find the version of perl?
Message-Id: <3A87659A.8DDFD74@ga.prestige.net>


--------------2AE2D13A5C03BB61E08EB713
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

perl --version heh ;)
terminalsplash wrote:

> Hi,
>
>    How can i find the which versin of perl i'm using?
> I have perl in both NT and LINUX.It was already installed. what is te
> command i should use to get the version?
>
> Thanks in advance

--
A little experience often upsets a lot of theory.



--------------2AE2D13A5C03BB61E08EB713
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
perl --version heh ;)
<br>terminalsplash wrote:
<blockquote TYPE=CITE>Hi,
<p>&nbsp;&nbsp; How can i find the which versin of perl i'm using?
<br>I have perl in both NT and LINUX.It was already installed. what is
te
<br>command i should use to get the version?
<p>Thanks in advance</blockquote>

<pre>--&nbsp;
A little experience often upsets a lot of theory.</pre>
&nbsp;</html>

--------------2AE2D13A5C03BB61E08EB713--



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

Date: Mon, 12 Feb 2001 16:58:09 -0500
From: "henroc" <henroc@mindspring.com>
Subject: Re: how to find the version of perl?
Message-Id: <969ma9$qrh$1@nntp9.atl.mindspring.net>

"perl -v" (without the quotes) entered on the command line will return the
version number.
"perl -h" will give you a listing of command line options.

henry

"terminalsplash" <shino_korah@yahoo.com> wrote in message
news:969kin$seg@news.or.intel.com...
> Hi,
>
>    How can i find the which versin of perl i'm using?
> I have perl in both NT and LINUX.It was already installed. what is te
> command i should use to get the version?
>
> Thanks in advance
>
>
>




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

Date: Mon, 12 Feb 2001 22:11:59 -0000
From: doughera@maxwell.phys.lafayette.edu (Andy Dougherty)
Subject: Re: Installation Problems with Perl 5.6 on NCR Box
Message-Id: <slrn98gnvt.7j4.doughera@maxwell.phys.lafayette.edu>

In article <DUSh6.2481$hQ5.13284@skycache.prestige.net>, 
J. Morris Cook, Jr. wrote:
>I am attempting to install Perl 5.6 on an NCR SVR4 Unix box running MPRAS,
>with all current patches to OS. When I run make, I get the following error
>as it dies:
>
>w "toke.c",L4976: Perl_yylex: Global CSE elimination suppressed; function is
>too
> big.
>Memory exhausted (malloc returned 0)
>While allocating 16000 byte chunk for pool live/dead vectors

It looks like your compiler is unable to compile toke.c with your
selected level of optimization.  Try recompiling just toke.c by hand
without optimization.  (If you wish to do it "automatically", see the
INSTALL file for how to change the optimization.  Look for
'optimize'.)

Previous experience has been that reg*.c also have problems on this
platform, so while you're at it, compile those files without
optimization too.

Hope this helps,

    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042


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

Date: Mon, 12 Feb 2001 16:28:41 -0500
From: Keith Harrison <harriso2@pilot.msu.edu>
Subject: Looking for alternative to Google (was deja) newsgroup search
Message-Id: <MPG.14f21f95f09b6643989689@msunews.cl.msu.edu>

Google has taken over the newsgroup search site www.deja.com and changed 
the format to, in my opinion, an inferior one. Does anyone know of 
another site that's comparable to the old deja?


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

Date: 12 Feb 2001 16:40:34 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Looking for alternative to Google (was deja) newsgroup search
Message-Id: <m31yt3lgvh.fsf@mumonkan.sunstarsys.com>

Keith Harrison <harriso2@pilot.msu.edu> writes:

> Google has taken over the newsgroup search site www.deja.com and changed 
> the format to, in my opinion, an inferior one. Does anyone know of 
> another site that's comparable to the old deja?

Here's a list:

  http://directory.google.com/Top/Computers/Usenet/Web_Based/

Ah, the irony.

-- 
$.=$[|3*rand;$_=67014523;END{print@_};*UNIVERSAL::AUTOLOAD=sub{&A;pop->();++
$#;*A};$.++,*[=*]=*\=sub{$].=pop.(--$#%2?q: ::qq::)};*#=sub{split m, (?<=^.{2})
(.{$.}),x,shift};@#=qw[just another Perl hacker];*A=*AUTOLOAD=sub{split"::",$A;
&]};map{splice@#,$_,1,&#($#[$_])}3,1;$_="@{[@#[m$.$g]]}";s;P;,p;;eval;$\.="\n"


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

Date: Mon, 12 Feb 2001 21:30:10 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: LWP debug
Message-Id: <G8nyEA.95I@news.boeing.com>

In article <968mef$ta0$1@nnrp1.deja.com>,  <dweisinger@my-deja.com> wrote:
>I've tried to automate the POST action on some CGI forms
>by using LWP::UserAgent.
>I've been successful with about 30 of the 35 forms.
>The remaining 5 forms are bugging me.
>I'm not sure what's wrong or why these forms are less forgiving than
>the other ones...
>Is there a way to debug LWP?  The response just gives me some standard
>error.


>Is there a way to see what HTTP message is being sent from a browser
>where the form works?
>
>

LWP::Debug (bundled with libwww) may help  or even a 
full fledged sniffer. See, Tim Meadowcroft's nice tool 
"httpSniffer" (http://www.compansr.demon.co.uk)

hth,
--
Charles DeRykus


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

Date: Mon, 12 Feb 2001 15:36:50 -0500
From: Janet Schlueb <jgs2283@MailAndNews.com>
Subject: Need help with an array
Message-Id: <3A8A58E4@MailAndNews.com>

Hello, I know that this isn't too difficult of a question, but I was 
wondering 
if anyone could tell me how to do this in one statement rather than 22:

$rqst = HTTP::Request->new('GET', $PageUrl);
$rqst = HTTP::Request->new('GET', $PageUrl2);
$rqst = HTTP::Request->new('GET', $PageUrl3);
$rqst = HTTP::Request->new('GET', $PageUrl4);
$rqst = HTTP::Request->new('GET', $PageUrl5);
$rqst = HTTP::Request->new('GET', $PageUrl6);
$rqst = HTTP::Request->new('GET', $PageUrl7);
$rqst = HTTP::Request->new('GET', $PageUrl8);
$rqst = HTTP::Request->new('GET', $PageUrl9);
$rqst = HTTP::Request->new('GET', $PageUrl10);
$rqst = HTTP::Request->new('GET', $PageUrl11);
$rqst = HTTP::Request->new('GET', $PageUrl12);
$rqst = HTTP::Request->new('GET', $PageUrl13);
$rqst = HTTP::Request->new('GET', $PageUrl14);
$rqst = HTTP::Request->new('GET', $PageUrl15);
$rqst = HTTP::Request->new('GET', $PageUrl16);
$rqst = HTTP::Request->new('GET', $PageUrl17);
$rqst = HTTP::Request->new('GET', $PageUrl18);
$rqst = HTTP::Request->new('GET', $PageUrl19);
$rqst = HTTP::Request->new('GET', $PageUrl20);
$rqst = HTTP::Request->new('GET', $PageUrl21);
$rqst = HTTP::Request->new('GET', $PageUrl22);

Thank you in advance!

------------------------------------------------------------
 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or
 POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------



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

Date: Mon, 12 Feb 2001 21:59:15 GMT
From: egwong@netcom.com
Subject: Re: Need help with an array
Message-Id: <T0Zh6.6778$y03.441934@news.flash.net>

Janet Schlueb <jgs2283@mailandnews.com> wrote:
> Hello, I know that this isn't too difficult of a question, but I was 
> wondering 
> if anyone could tell me how to do this in one statement rather than 22:

> $rqst = HTTP::Request->new('GET', $PageUrl);
> $rqst = HTTP::Request->new('GET', $PageUrl2);
> $rqst = HTTP::Request->new('GET', $PageUrl3);
[ etc. ]

I'm assuming you want to do all of these in a loop, otherwise your
entire sequence simply reduces to

  $rqst = HTTP::Request->new('GET', $PageUrl22);

the last statement.

The best thing to do is to use an array to store all of your urls rather
than having each one in its own scalar variable.  Then you can do

  foreach ( @page_urls ) {
	my $rqst = HTTP::Request->new('GET', $_);
	...
  }

See the perldata manpage.

I guess you couls also use symbolic references, but I wouldn't if I
were you (see perlref manpage).  That look something like

  for ("", 2..22) {
	my $rqst = HTTP::Request->new('GET', ${"PageUrl$_"});
	...
  }

This would mean all of your $PageURL??? variables would have to be
package variables (rather than lexicals) and that's not a Good Thing,
so forget I even mentioned it, okay?

ERic


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

Date: Mon, 12 Feb 2001 22:25:16 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Need help with an array
Message-Id: <3a8862cb.1676$227@news.op.net>

[mailed and posted]
In article <3A8A58E4@MailAndNews.com>,
Janet Schlueb  <jgs2283@MailAndNews.com> wrote:
>Hello, I know that this isn't too difficult of a question, but I was 
>wondering 
>if anyone could tell me how to do this in one statement rather than 22:
>
>$rqst = HTTP::Request->new('GET', $PageUrl);
>$rqst = HTTP::Request->new('GET', $PageUrl2);
>$rqst = HTTP::Request->new('GET', $PageUrl3);

The right approach is to have the page urls in a snigle array variable
instead of in 23 similarly-named but unrelated scalar variables.

If the URLs are in an array, say @PageUrl, then you use
        for $url (@PageURL) {
          $request = HTTP::Request->new('GET', $url);
        }


Any time you have variables named $PageUrl1, $PageURL2, and so on, it
means you made a mistake, and you should have been using an array all
along.  With the array, you can still refer to the individual urls as
$PageUrl[0], $PageUrl[1], ... $PageUrl[22], but you may also refer to
the URLs as a group using the @PageUrl notation I showed above.

See 
        http://www.perl.com/pub/2000/04/raceinfo.html
for more discussion of this point.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 12 Feb 2001 22:55:51 -0000
From: "Phil Whitby" <philw@hotpop.com>
Subject: newbie problem installing "subscribe me" mailing list
Message-Id: <qPZh6.192$mO6.14037@news6-win.server.ntlworld.com>

i am getting the following error when trying to run a "subscribe me lite"
script for a mailing list:

Premature end of script headers:
/data1/hm/gigcentre/cgi-bin/subscribeme/subscribe.pl

my server is hypermart.net

can anyone help:

please e-mail me with any advice
Thanks
Phil Whitby




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

Date: Mon, 12 Feb 2001 21:25:30 GMT
From: Jozxyqk <jfeuerst@eecs.tufts.edu>
Subject: Perl and Linux Package Managers (rpm/deb)
Message-Id: <exYh6.368$3V5.135866@typhoon.ne.mediaone.net>

Here is a question of curiosity, and I apologize if it's going
to attract flames; that's not the intention.
I have a very old Red Hat Linux box, and decided to install
perl from tarball instead of RPM at the time.

I'm thinking of wiping that box and creating a new Debian system.
and pondering installing it as a deb.

My question is this:
If you've installed perl from a linux package management system,
what happens when you try to use CPAN to install new modules,
when CPAN tells you you must upgrade perl to 5.6, etc?  _Can_
you use CPAN when youre depending on a package manager?

Should that be something to worry about?  Does it really matter?
Or do Debian Perl hackers generally install perl from tar, just for
flexibility's sake (and up-to-dateness's sake)?

Thanks.



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

Date: Mon, 12 Feb 2001 21:41:10 GMT
From: egwong@netcom.com
Subject: Re: Perl and Linux Package Managers (rpm/deb)
Message-Id: <WLYh6.6772$y03.439506@news.flash.net>

Jozxyqk <jfeuerst@eecs.tufts.edu> wrote:
> Here is a question of curiosity, and I apologize if it's going
> to attract flames; that's not the intention.
> I have a very old Red Hat Linux box, and decided to install
> perl from tarball instead of RPM at the time.

> I'm thinking of wiping that box and creating a new Debian system.
> and pondering installing it as a deb.
[ cut ]

Hey,

I've got Debian (potato) on my computer and, so far as linux distros
are concerned, I highly recommend it.  There's no problem installing
modules from CPAN (either with "perl -MCPAN -e shell" or downloading
the tar.gz and doing it manually.)  Also, a lot of CPAN modules are
available as .deb's.

One thing, with potato at least, is that Config.pm is supposed to be
slightly broken.  Apparently you need to change "installprivlib" to
"privlibexp".  This was an issue trying to install Inline-0.31.

The Debian/potato perl is perl 5.005_03, so if you want to install
perl 5.6, you need to do it from the tar file.  Parallel installations
of perl aren't a problem though, since you can keep everything
in its own directory with
  sh Configure-Dprefix=/usr/local/perl-5.6.1

or whatever.  That's what I'd recommend doing so when the "official"
Debian-delivered perl catches up, you can just wipe your secondary
installation.

Good luck,
ERic


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

Date: Mon, 12 Feb 2001 21:49:33 GMT
From: Jozxyqk <jfeuerst@eecs.tufts.edu>
Subject: Re: Perl and Linux Package Managers (rpm/deb)
Message-Id: <NTYh6.379$3V5.141152@typhoon.ne.mediaone.net>

> The Debian/potato perl is perl 5.005_03, so if you want to install
> perl 5.6, you need to do it from the tar file.  Parallel installations
> of perl aren't a problem though, since you can keep everything
> in its own directory with
>   sh Configure-Dprefix=/usr/local/perl-5.6.1

 ...but what happens when, as I've seen it do, the CPAN shell decides that
you *require* a higher version (i.e. perl 5.6) for a certain module, and 
forces an upgrade, before you can intervene?



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

Date: Mon, 12 Feb 2001 22:35:44 GMT
From: egwong@netcom.com
Subject: Re: Perl and Linux Package Managers (rpm/deb)
Message-Id: <4zZh6.6792$y03.441934@news.flash.net>

Jozxyqk <jfeuerst@eecs.tufts.edu> wrote:
> ...but what happens when, as I've seen it do, the CPAN shell decides that
> you *require* a higher version (i.e. perl 5.6) for a certain module, and 
> forces an upgrade, before you can intervene?

Dunno.  Never seen that.  The CPAN shell always asks me if I want
to download/upgrade something before it does it.



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

Date: Mon, 12 Feb 2001 13:07:05 -0600
From: "Joe Halbrook" <jhalbrook@bjcmail.carenet.org>
Subject: Re: Perl DBI -  Can't call method "prepare" on an undefined value
Message-Id: <WyWh6.422588$w61.472600@dfw-read.news.verio.net>

Thank you, Tore.  I'll incorporate your suggestions.

Joe

Tore Aursand <tore@extend.no> wrote in message
news:MPG.14f24e655438c00f9898a3@news.online.no...
> In article <MHUh6.422542$w61.472118@dfw-read.news.verio.net>,
> jhalbrook@bjcmail.carenet.org says...
> > If I need to connect to mulitple tables in a database,
> > can I connect to the database once, then reset my $sth
> > handle in successive prepare methods to access the
> > tables.
>
> You don't connect to the tables in a database - you connect only to the
> database itself.
>
> > $sql   = qq{ SELECT blahblah FROM blahTable WHERE blahVar LIKE
%blahh%" };
> > $sth->execute();
>
> This is _very_ wrong.  SQL statements should always (...) be like this;
>
>   my $sth = $dbh->prepare(...);
>   $sth->execute();
>   # Process the data here
>   $sth->finish();
>
> When you connect (and disconnect to the database), you should do
> something like this;
>
>   unless (defined $dbh) {
>       $dbh = DBI->connect(...);
>       unless (defined $dbh) {
>          # Something went wrong
>       }
>   }
>
> This is the way I do it, 'cause it will keep the database connection in
> memory when running mod_perl.
>
> >  sub connect_db {
> >
> >     if ($connected eq '0') {
> >         my $dbh =  DBI->connect(...);
> >         $connected = 1;
> >     }
> >
> >  }
>
> $dbh will in the example above only be visible inside the connect_db()
> subroutine.  The rest of the program will probably never 'see' it.
>
>
> --
> Tore Aursand - tore@extend.no - http://www.extend.no/~tore/




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

Date: 12 Feb 2001 17:06:56 -0500
From: Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu>
Subject: Perl FAQ: Stripping blank space
Message-Id: <wzdwvav1rpb.fsf@denali.ccs.neu.edu>

There exists in the Perl FAQ the question "How do I strip blank space
from the beginning/end of a string?"

Could the FAQ maintainer please add the question "Why doesn't Perl
include a built in function to do this?" 

-Jeff


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

Date: 12 Feb 2001 17:49:44 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Perl FAQ: Stripping blank space
Message-Id: <m3wvavjz3r.fsf@mumonkan.sunstarsys.com>

Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu> writes:

> There exists in the Perl FAQ the question "How do I strip blank space
> from the beginning/end of a string?"
> 
> Could the FAQ maintainer please add the question "Why doesn't Perl
> include a built in function to do this?" 

What do you suggest the answer should be?

A : Perl has a regexp engine that can do this trivially.
    Hence, Perl doesn't need an extremely specialized function
    (Perl already has it's fair share of those.) If you really 
    want to, you could always write your own:

  # removes leading and trailing spaces from its (lvalue) arguments
  # usage similar to chomp: strip($var1, $var2);    

        sub strip { 
            for (@_) { 
                s/^\s+//;
                s/\s+$//;
            }
            return @_;
        }



But that's not significantly different from the faq answer in:

  % perldoc -q strip

-- 
Joe Schaefer    "Don't go around saying the world owes you a living. The world
                            owes you nothing- it was here first."
                                               --Mark Twain


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

Date: Tue, 13 Feb 2001 10:24:02 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: postgres perl problem
Message-Id: <969k9k$1id$1@hermes.nz.eds.com>


"John Joseph Trammell" <trammell@bayazid.hypersloth.net> wrote in message
news:slrn98fur9.vvh.trammell@bayazid.hypersloth.net...
> On Mon, 12 Feb 2001 08:33:37 +0100, Tony Dalbrekt <to.da@spray.se> wrote:
> > Can't locate pg.pm in @INC (@INC contains:
/usr/lib/perl5/5.6.0/i386-linux
> > /usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-linux
> > /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at
> > /home/toda/html//cgi-bin/test.cgi line 8.
> >
> > Why do I get this error message every time I try to connect to my
postgres
> > database.
>
> Probably because of that bug on line 32 of your code.

Actually, it's line 8




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V10 Issue 275
**************************************


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