[18078] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 238 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 7 18:21:10 2001

Date: Wed, 7 Feb 2001 15:20:41 -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: <981588041-v10-i238@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 7 Feb 2001     Volume: 10 Number: 238

Today's topics:
        Problems with Perl on Apache? <dk_sz@hotmail.com>
        scripts does be executed - but nothing happens :-( <c.gersch@team.isneurope.com>
        Setting Cookie Expiration Date with Perl <kdiffily@webpageweaver.com>
    Re: Setting Cookie Expiration Date with Perl andre_sanchez@my-deja.com
    Re: shift vs splice in boolean context, why do they act (Tad McClellan)
        splitting a string on the / character <mgj1@ukc.ac.uk>
    Re: splitting a string on the / character (Abigail)
    Re: splitting a string on the / character <mgj1@ukc.ac.uk>
    Re: splitting a string on the / character <ccx138@coventry.ac.uk>
    Re: Threading in Perl <anonymous@anonymous.anonymous>
        turning tables dif colors <eyoung@noway.com>
    Re: turning tables dif colors <mothra@nowhereatall.com>
    Re: turning tables dif colors (Abigail)
        using java classes in perl mark_lybarger@my-deja.com
    Re: waiting for a file to be created <mischief@velma.motion.net>
    Re: XML::Parser question kumar22@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 7 Feb 2001 23:23:52 +0100
From: "Thomas Schulz" <dk_sz@hotmail.com>
Subject: Problems with Perl on Apache?
Message-Id: <95shsb$aud$1@news.inet.tele.dk>

I use ActiveState Perl,  Apache 1.3.14 and Windows 2000 Pro.
ActiveStatePerl is loacted: D:\webserve\perl\bin.
Apache is loacted: D:\webserve\Apache.
Apache is standard setup (with includes enabled though in options - e.g. my
"echo" and "include" works fine). As a side note I also have PHP working
(but i think I would like to try Perl instead as it seems to be more
"programmer" orientated). I use "/" instead of "\" in my Apache httpd.conft
as that is explicitly written in the help/comments in the config file.

My problem is. Where "hello world" is supposed to show up.. I get an empty
line in my output. here is my "test scenario".

[D:\webserve\apache\htdocs; testperl.shtml;]
<html>
<!--#exec cgi="/cgi-bin/helloworld.pl"-->
</html>

[D:\webserve\apache\cgi-bin; helloworld.pl;]
#!c:/webserve/perl/bin
print "Content-type: text/html\n\n";
print "Hello, world";


Anyone here has an Apache/Perl config that works? What Perl distribution?
Could anyone maybe send their httpd.conf (that is, if noone has a suggestion
that works) where Perl works on?


Kind regards,
Thomas Schulz








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

Date: Wed, 7 Feb 2001 21:16:22 +0100
From: "Christian Gersch" <c.gersch@team.isneurope.com>
Subject: scripts does be executed - but nothing happens :-(
Message-Id: <95saeo$gk9$00$1@news.t-online.com>

Hi there.

The script here (please scroll down) should delete the subfolders of a
folder with its files if the subfolder is older than 5 minutes.
Executed at the Telnet shell, the script does work...well, I don't get any
error - but nothing happend to the directories.

Could you please check my code?
Thank you very much!

-Chris

==== CODE:START ====
#!/usr/bin/perl -w
use strict;
use File::stat;

my $verbose = 0;
my $nop = 0;

sub usage {
    print STDERR "Usage: $0 [-d days] dir ...\n";
    exit(1);
}

sub cleandir {
    my ($dir, $since, $level) = (@_);
    my $notremoved = 0;

    if ($verbose > 1) {
 print STDERR "$0:", " " x $level, " cleandir $dir $since {\n";
    }
    if (!opendir(DIR, $dir)) {
 printf STDERR "$0:", " " x $level, " cannot opendir $dir: $!";
 return;
    }
    for my $i (readdir(DIR)) {
 if ($i eq "." || $i eq "..") {next}
 if ($verbose > 2) {
     print STDERR "$0:", " " x $level, " checking $dir/$i\n";
 }
 my $st = lstat("$dir/$i");
 if ($verbose > 3) {
     print STDERR "$0:", " " x $level, " mtime=", $st->mtime, " atime=",
$st->atime, "\n";
 }
 if (-d _) {

     if (cleandir("$dir/$i", $since, $level+1) == 0 && $st->mtime < $since)
{
  if (rmdir("$dir/$i")) {next}
     }
 } elsif ($st->mtime < $since && $st->atime < $since) {
     if ($nop) {
  print "would remove $dir/$i\n";
     } else {
  if ($verbose > 0) {
      print STDERR "$0:", " " x $level, " removing $dir/$i\n";
  }
  if (unlink("$dir/$i")) {next}
  print STDERR "$0:", " " x $level, " removing $dir/$i failed: $!/$i\n";
     }

 }
 $notremoved++;
    }
    if ($verbose > 1) {
 print STDERR "$0:", " " x $level, " cleandir: $notremoved }\n";
    }
    return $notremoved;
}


sub main {
    my $since = time();;
    my $i;
    while ($i =$i) {
 if ($i eq "-d") {
     my $days = shift(@ARGV);
     $since = time();
 } elsif ($i eq "-v") {
     $verbose++;
 } elsif ($i eq "-n") {
     $nop++;
 } else {
     cleandir($i, $since, 0);
 }
    }
    exit(0);
}


main();
==== CODE:ENDE====

Thanks :-)

-Chris
--
Christian Gersch, chris@team.isneurope.com
:: www.neukunden.myisn.de - Geld für Ihre Startseite ::




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

Date: Wed, 07 Feb 2001 14:54:09 -0500
From: Kevin Diffily <kdiffily@webpageweaver.com>
Subject: Setting Cookie Expiration Date with Perl
Message-Id: <B6A71211.10E6%kdiffily@webpageweaver.com>

I am trying to set a variable for cookie expiration dates.  The amount of
time in the future will be x number of days from the date that the cookie is
set.  I found some helpful postings at deja.com but am having a little
trouble with the correct formatting for the date.  The relevant parts of the
script follow:

set_cookie_exp(180);
$expiration = $cookieexpire;

###############################################################
#    set_cookie_exp
#    Sets the time in GMT Format for a cookie's expiration
#    Example syntax
#    set_cookie_exp (30) will set the value of $cookieexpire to
#    30 days in the future in GMT Format
#    This needs to display in the following format Wdy, DD-Mon-YYYY HH:MM:SS
#    GMT
#    which at present it is not
###############################################################
sub set_cookie_exp {
$days = "@_";
$daysxseconds = ($days * 86400);

$gmtcookieexpire=(scalar gmtime(time+$daysxseconds));
$cookieexpire= "$gmtcookieexpire" . "GMT";
}

###############################################################



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

Date: Wed, 07 Feb 2001 22:29:11 GMT
From: andre_sanchez@my-deja.com
Subject: Re: Setting Cookie Expiration Date with Perl
Message-Id: <95si7a$9sm$1@nnrp1.deja.com>

In article <B6A71211.10E6%kdiffily@webpageweaver.com>,
  Kevin Diffily <kdiffily@webpageweaver.com> wrote:
> I am trying to set a variable for cookie expiration dates.  The amount
of
> time in the future will be x number of days from the date that the
cookie is
> set.

From: http://stein.cshl.org/WWW/software/CGI/#cookies

$cookie = $query->cookie(-name=>'sessionID',
			 -value=>'xyzzy',
			 -expires=>'+1h',
			 -path=>'/cgi-bin/database',
			 -domain=>'.capricorn.org',
			 -secure=>1)	;

print $query->header(-cookie=>$cookie)	;

+30s                              30 seconds from now
+10m                              ten minutes from now
+1h                               one hour from now
-1d                               yesterday (i.e. "ASAP!")
now                               immediately
+3M                               in three months
+10y                              in ten years time
Thu, 25-Apr-1999 00:40:33 GMT     at the indicated time & date


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 07 Feb 2001 20:13:09 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: shift vs splice in boolean context, why do they act differently
Message-Id: <slrn9834ch.ae3.tadmc@tadmc26.august.net>

Yary Hluchan <fecundfec@my-deja.com> wrote:
>Subject: shift vs splice in boolean context, why do they act differently


They are not in "boolean" (scalar) context, they are in list context,
provided by the assignment operator.  Try it without the parens 
around ($a) to get scalar context for shift() and splice().


>Can someone explain this example to me? Why does the first assignment
>return true while the second returns false?


They are both "list assignments", ie. a list on both sides of
an assignment operator.

shift() returns undef, which is DWIMed into a 1-element list and 
assigned to $a. A list assignment in scalar (boolean) context returns
the number of elements in the list (perldoc perldata), which is one,
a "true" value.

splice() returns an empty list. Number of elements in list is zero,
a false value.


>  DB<1> @x=(); if (($a)= shift @x){print "yes"}
>yes
>  DB<2> @x=(); if (($a)=splice @x,0,1){print "yes"}


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 07 Feb 2001 22:08:54 +0000
From: mgj1 <mgj1@ukc.ac.uk>
Subject: splitting a string on the / character
Message-Id: <3A81C776.1C7C@ukc.ac.uk>

Hi,
I was wondering if anyone knew how to split a string using the /
character, for example the line which won't work is :

my @temp = split ///, $direntry;

because of the /// part, whereas if i wanted to split on a 'b' say the
line:

my @temp = split /b/, $direntry;

obviously will work.
Is there a way of splitting on the / character?

thanks in advance,
Mark.


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

Date: 7 Feb 2001 22:11:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: splitting a string on the / character
Message-Id: <slrn983i0s.258.abigail@tsathoggua.rlyeh.net>

mgj1 (mgj1@ukc.ac.uk) wrote on MMDCCXVII September MCMXCIII in
<URL:news:3A81C776.1C7C@ukc.ac.uk>:
?? Hi,
?? I was wondering if anyone knew how to split a string using the /
?? character, for example the line which won't work is :
?? 
?? my @temp = split ///, $direntry;
?? 
?? because of the /// part, whereas if i wanted to split on a 'b' say the
?? line:
?? 
?? my @temp = split /b/, $direntry;
?? 
?? obviously will work.
?? Is there a way of splitting on the / character?


Several ways.

Did you study the perlop and perlre man pages?



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Wed, 07 Feb 2001 22:19:33 +0000
From: Mark James <mgj1@ukc.ac.uk>
Subject: Re: splitting a string on the / character
Message-Id: <3A81C9F5.2E30@ukc.ac.uk>

Abigail wrote:
[snip]
> 
> Several ways.
> 
> Did you study the perlop and perlre man pages?
> 
> Abigail
> --

i had no idea they existed, but i've read through the perl faq and
didn't find anything about it in there.
looks like i'll be reading for ages here :(
any hints? ;)
cheers,
mark.


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

Date: Wed, 07 Feb 2001 22:13:14 +0000
From: JMT <ccx138@coventry.ac.uk>
Subject: Re: splitting a string on the / character
Message-Id: <3A81C87A.A8302880@coventry.ac.uk>



Mark James wrote:

> Abigail wrote:
> [snip]
> >
> > Several ways.
> >
> > Did you study the perlop and perlre man pages?
> >
> > Abigail
> > --
>
> i had no idea they existed, but i've read through the perl faq and
> didn't find anything about it in there.
> looks like i'll be reading for ages here :(
> any hints? ;)
> cheers,
> mark.

Try escaping the /.
John.



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

Date: Wed, 07 Feb 2001 17:55:40 -0500
From: Anonymous <anonymous@anonymous.anonymous>
Subject: Re: Threading in Perl
Message-Id: <fik38to853ke1h381uqckb0ojd4aa4voum@4ax.com>

On Wed, 7 Feb 2001 10:10:41 -0000, "Andrew Ralph" <andrew_ralph@yahoo.com> wrote:

>Hi,
>
>I "inherited" some code that uses unix forking and I now need to port this
>to windows.
>
>Is there any threading support for perl in windows ?  I seem to remember
>looking a while ago and I couldn't really seem to find anything.  Does
>anyone know of something that I could use ?
>
>Thanks,
>
>Andy.
>

Leave it in Unix.  Windows is forked up.

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


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

Date: Wed, 07 Feb 2001 15:37:07 -0600
From: eyoung <eyoung@noway.com>
Subject: turning tables dif colors
Message-Id: <3A81C003.3A99C41@noway.com>

I just got my first "Best of Dreamweaver/Fireworks/Flash Report", it is
filled with mistakes. I want to figure out one of them. They give some
javascript to turn tables diffrent colors. Any idoit can clearly see
that their code will not work they have open brackets that they never
close. I want to know the correct way to do this...gave it a try but my
attempt did not work.....help!

THEIR CODE:

IN THE HEAD

<script language="JavaScript">
<!--
function FirstColumnRollOver(cchange) {if
(!cchange.contains(event.fromElement)] {cchange.bgColor="#FF66FF";)}
function FirstColumnRollOver(cchange) {if
(!cchange.contains(event.toElement)] {cchange.bgColor="#FFCCFF";)}
function SecondColumnRollOver(cchange) {if
(!cchange.contains(event.fromElement)] {cchange.bgColor="#6666FF";)}
function SecondColumnRollOver(cchange) {if
(!cchange.contains(event.toElelment)] {change.bgColor="CCCCFF";)}

//-->
</script>


IN THE BODY:

<table width="75%" border="1">
  <tr>
    <td bgcolor="CCCCFF" onMouseOver=FirstColumnRollOver(this);
onMouseOut=FirstColumnRollOut(this)>Row1 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver=SecondColumnRollOver(this);
onMouseOut=SecondColumnRollOut(this)>Row1 Col2</td>
  </tr>
  <tr>
    <td bgcolor="CCCCFF" onMouseOver=FirstColumnRollOver(this);
onMouseOut=FirstColumnRollOut(this)>Row2 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver=SecondColumnRollOver(this);
onMouseOut=SecondColumnRollOut(this)>Row2 Col2</td>
  </tr>
  <tr>
    <td bgcolor="CCCCFF" onMouseOver=FirstColumnRollOver(this);
onMouseOut=FirstColumnRollOut(this)>Row3 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver=SecondColumnRollOver(this);
onMouseOut=SecondColumnRollOut(this)>Row3 Col2</td>
  </tr>
  <tr>
    <td bgcolor="CCCCFF" onMouseOver=FirstColumnRollOver(this);
onMouseOut=FirstColumnRollOut(this)>Row4 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver=SecondColumnRollOver(this);
onMouseOut=SecondColumnRollOut(this)>Row4 Col2</td>
  </tr>
</table>
</body>
</html>


I did my best to correct their code...not sure what I did in the body
does any good or not but I think I fixed the problem in the
head....still doesn't work.
MY CHANGES:

IN THE HEAD

<script language="JavaScript">
<!--
function FirstColumnRollOver(cchange) {if
(!cchange.contains(event.fromElement)) {cchange.bgColor="#FF66FF";}}
function FirstColumnRollOver(cchange) {if
(!cchange.contains(event.toElement)) {cchange.bgColor="#FFCCFF";}}
function SecondColumnRollOver(cchange) {if
(!cchange.contains(event.fromElement)) {cchange.bgColor="#6666FF";}}
function SecondColumnRollOver(cchange) {if
(!cchange.contains(event.toElelment)) {change.bgColor="CCCCFF";}}

//-->
</script>


IN THE BODY:

<table width="75%" border="1">
  <tr>
    <td bgcolor="CCCCFF" onMouseOver="FirstColumnRollOver(this)";
onMouseOut="FirstColumnRollOut(this)">Row1 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver="SecondColumnRollOver(this)";
onMouseOut="SecondColumnRollOut(this)">Row1 Col2</td>
  </tr>
  <tr>
    <td bgcolor="CCCCFF" onMouseOver="FirstColumnRollOver(this)";
onMouseOut="FirstColumnRollOut(this)">Row2 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver="SecondColumnRollOver(this)";
onMouseOut="SecondColumnRollOut(this)">Row2 Col2</td>
  </tr>
  <tr>
    <td bgcolor="CCCCFF" onMouseOver="FirstColumnRollOver(this)";
onMouseOut="FirstColumnRollOut(this)">Row3 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver="SecondColumnRollOver(this)";
onMouseOut="SecondColumnRollOut(this)">Row3 Col2</td>
  </tr>
  <tr>
    <td bgcolor="CCCCFF" onMouseOver="FirstColumnRollOver(this)";
onMouseOut="FirstColumnRollOut(this)">Row4 Col1</td>
    <td bgcolor="FFCCFF" onMouseOver="SecondColumnRollOver(this)";
onMouseOut="SecondColumnRollOut(this)">Row4 Col2</td>
  </tr>
</table>
</body>
</html>



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

Date: Wed, 07 Feb 2001 13:43:11 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: turning tables dif colors
Message-Id: <3A81C16F.5CD61573@nowhereatall.com>

eyoung wrote:
> 
> I just got my first "Best of Dreamweaver/Fireworks/Flash Report", it is
> filled with mistakes. I want to figure out one of them. They give some
> javascript to turn tables diffrent colors. Any idoit can clearly see
> that their code will not work they have open brackets that they never
> close. I want to know the correct way to do this...gave it a try but my
> attempt did not work.....help!
> 
Why have you posted this in a perl news group? There is not one line of
perl code here?
Please post to the correct newsgroup

Mothra


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

Date: 7 Feb 2001 22:02:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: turning tables dif colors
Message-Id: <slrn983hf2.258.abigail@tsathoggua.rlyeh.net>

eyoung (eyoung@noway.com) wrote on MMDCCXVII September MCMXCIII in
<URL:news:3A81C003.3A99C41@noway.com>:
@@ I just got my first "Best of Dreamweaver/Fireworks/Flash Report", it is
@@ filled with mistakes.

And your Perl issue is?


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Wed, 07 Feb 2001 22:07:21 GMT
From: mark_lybarger@my-deja.com
Subject: using java classes in perl
Message-Id: <95sgui$8ls$1@nnrp1.deja.com>

can someone tell me if it's possible to use java classes from within
perl?  i have some java classes I recieved from an external source and
need to use them in a CGI app. i'm looking into alternatives to using a
java-servelett implementation (don't wanna buy a servelette enging?).

thanks!


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 07 Feb 2001 21:48:32 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: waiting for a file to be created
Message-Id: <t83glgeisntcaa@corp.supernews.com>

Peter John Cameron <peterca@ukgateway.net> wrote:
> I have a perl script that's called from a Java application. The script uses
> an open call to start a statistical application that is fed input from  Java
> via the perl script. The complicating factor is that the stats app creates a
> file which the perl script is then expecting to process. However, the perl
> code is proceeding to process the as yet non-existant file. It all works if
> I pause the script by putting a for loop after the open's close. This gives
> time for the stats app to finish creating the file (note, the file is
> created internally by the stats app and not by redirection). But a for loop
> is a messy solution, and not platform independent: a 1GHz computer may
> require a large loop counter for instance. I thought the close would be
> enough, but it obviously isn't.

Via a piped open? I see no code, but from "an open call to start
a statistical application" this is what I understand to be the case.

You could fork() and exec() the other process explicitly, then wait()
for it to end before continuing with your program.

You could also test for the existence of the file.
perldoc perlfunc ( and search for q<-X> )

> In another perl script used by the Java, there's a system call to invoke
> another app that produces needed files. This works fine, but in this
> situation the app called by system doesn't need any input.

This isn't the problem. You need to either make sure the file exists
or make sure the process creating it is finished running.

Chris

-- 
Christopher E. Stith

Parking for people we like only. All other vehicles will be vandalized.



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

Date: Wed, 07 Feb 2001 19:01:04 GMT
From: kumar22@my-deja.com
Subject: Re: XML::Parser question
Message-Id: <95s619$to6$1@nnrp1.deja.com>

Bart, Tad & Martien:  Many many thanks, that's a lot to read & play
with.  "CompactTree" and Martien's example are great.

-Rakesh

--
This ball of the Lords of Death -- it is just a spherical knife.

-Popol Vuh


Sent via Deja.com
http://www.deja.com/


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

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 238
**************************************


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