[28584] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9948 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 10 06:05:51 2006

Date: Fri, 10 Nov 2006 03:05:07 -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, 10 Nov 2006     Volume: 10 Number: 9948

Today's topics:
    Re: "Did not find leading dereferencer" - new findings  <ro.naldfi.scher@gmail.com>
    Re: FAQ 6.9 What is "/o" really for? <john@castleamber.com>
    Re: FAQ 6.9 What is "/o" really for? <rvtol+news@isolution.nl>
    Re: Generate HTML from a Windows Network Share <robgmatthews@gmail.com>
    Re: Generate HTML from a Windows Network Share <josef.moellers@fujitsu-siemens.com>
    Re: Generate HTML from a Windows Network Share <bik.mido@tiscalinet.it>
    Re: Generate HTML from a Windows Network Share <scobloke2@infotop.co.uk>
        guaranteeing interrupt handling <badarisj@gmail.com>
    Re: how to source an environment file <ced@blv-sam-01.ca.boeing.com>
    Re: how to source an environment file anno4000@radom.zrz.tu-berlin.de
        LAN Crawler <mmanocha@gmail.com>
        Net::FTP Wierdness; or Not..... huntingseasonson@gmail.com
    Re: Net::FTP Wierdness; or Not..... <benmorrow@tiscali.co.uk>
        new CPAN modules on Fri Nov 10 2006 (Randal Schwartz)
    Re: PERL can't open file for logging (world writable di (reading news)
    Re: PERL can't open file for logging (world writable di <joe@inwap.com>
    Re: perl command line arguements <benmorrow@tiscali.co.uk>
    Re: Perl runtime error after installing oracle 10g <mabounajm@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Nov 2006 02:23:41 -0800
From: "Ronny" <ro.naldfi.scher@gmail.com>
Subject: Re: "Did not find leading dereferencer" - new findings to an old puzzle
Message-Id: <1163154220.941092.179310@f16g2000cwb.googlegroups.com>

Ben Morrow schrieb:
> Quoth "Ronny" <ro.naldfi.scher@gmail.com>:
> >
> > Ben Morrow schrieb:
> >
> > > Quoth "Ronny" <ro.naldfi.scher@gmail.com>:
> > > > Ferry Bolhar schrieb:
> > > > > "Did not find leading dereferencer":
> > > > >  "extract_variable" was expecting one of '$', '@', or '%' at the
> > > > > start of a variable, but didn't find any of them.
> > > > This doesn't make any sense. First, I don't include in my programs any
> > > > Text:: stuff. Second, this would not explain why the error message
> > > > changes to the real one, if, say, I remove one comment line from the
> > > > source code.
> > >
> > > Are you by any chance using any modules that set up source filters?
> > > Switch.pm, perhaps? These often use Text::Balanced to do their work, and
> > > it isn't quite as good at parsing Perl as it might be.
> >
> > Indeed I do have a
> >
> >    use Switch 'Perl6';
> >
> > in this module. Good point.
>
> Hmmm. You presumably don't want to rewrite your code not to use Switch;
> that would be my recommendation.

Actually, *this* is the least problem. The use Switch was in the code
only for
historic reason, and I have removed it. I don't know of course if
*this* was sufficient
to make the error go away: After all, the removal of the statement made
the code
a little bit smaller, so the problem might simply have disappeared for
*this* reason
(removing a comment line instead of the use Switch would have had the
same
effect). Since the code is still being changed a lot, I think I will
see during the
following weeks whether the removal of the Switch module will remedy
the situation.

> > > As usual, if you reduce your script to the *minimal* example which
> > > reproduces the problem (yes, in this case this might be a lot of work),
> > > and post it here, I'm sure someone can tell you what's going on.
> >
> > The problem with errors which occur only in "sufficiently big" source
> > files is that the minimal example is still fairly big. In my case, I
> > have reduced it to the extent that deleting one single character (for
> > example, the "#" in front of an empty comment line) already makes this
> > error go away.  Still, the source file is around 350 lines big.
>
> If the error really only occurs with large source files, then the
> obvious workaround is to split your module into two.

This certainly is, although I it surprised me that 350 lines - quite a
few of them
being comments - is already too large to be handled in a single module.
Think
of the cases where you document a module using perlpod - in this case,
the
POD documentation alone can easily approach 350 lines. What do you
think?

Ronald



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

Date: 10 Nov 2006 04:18:57 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: FAQ 6.9 What is "/o" really for?
Message-Id: <Xns9876E3016D3E3castleamber@130.133.1.4>

 
>     For example, here's a "paragrep" program:
> 
>             $/ = '';  # paragraph mode
>             $pat = shift;
>             while (<>) {
>                     print if /$pat/o;
>             }

Just a quick q:

doesn't:

$/ = '';
$pat = shift;
$regex = qr/$pat/;

while (<>) {
    	print if $regex;
}

do almost exactly the same (and has identical speed?).

If so, can this be added to the FAQ?

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Fri, 10 Nov 2006 10:30:42 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: FAQ 6.9 What is "/o" really for?
Message-Id: <ej1kee.1ek.1@news.isolution.nl>

John Bokma schreef:

>     print if $regex;

ITYM:

     print if /$regex/;

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: 9 Nov 2006 20:33:32 -0800
From: "rob" <robgmatthews@gmail.com>
Subject: Re: Generate HTML from a Windows Network Share
Message-Id: <1163133212.555292.156430@h54g2000cwb.googlegroups.com>

That was incredibly helpful. :)

I do have one more question thought..

I've now got the program reading a specified directory, gathering the
data from the directory and then outputting it to an html file just
fine ... however, I'd like to include the subdirectories that are
located in that directory .... is there a way to do this? Or will I
simply have to write a new section of code for each subdirectory that I
want to include in this report?

Here's an example of my code ::

my($my_path) = ('c:\\other\\');

opendir (DIR, $my_path) or die "Can't open $my_path";

my(@files) = grep {/.+\.\w{3}$/i} readdir(DIR);

closedir(DIR);

open (MYFILE, '>data.html');
foreach my $filename (files){print MYFILE "$filename\n";}

close (MYFILE);



Ian Wilson wrote:
> rob wrote:
> >
>
> I'd start with
>
> #!perl
> use strict;
> use warnings;
>
> > $path "\\network_share\"
>
> I'm probably over simplifying but ...
> 1. To assign a value to a variable use the equals sign.
> 2. Use single quotes unless interpolating variables into text.
> 3. It is usually prudent to use forward slashes not back slashes.
> 4. Terminate a statement with a semi-colon.
>
> >
> > opendir($path) \ die "Can't open $path";
>
> 1. Use the vertical bar for a high precendence "or".
> 2. For this circumstance, I prefer the word "or" instead.
>     (there are precedence pitfalls for the unwary)
>
> > @dirs=["other"];
>
> You probably need to use the readdir() function here.
>
> > closedir(dir)
>
> Missing semi-colon.
>
> >
> > print "<a href="\"$path">Test</a>
>
> 1. Unescaped superfluous quote after href=.
> 2. You didn't escape the other quote after the path.
> 3. No terminating quote.
> 4. No semi-colon.
>
> You probably want to print the filenames you just read.
>
> >
> > Am I looking at this in the right direction?
> >
>
> Yes, but you might need to consult an optician :-)
>
> You might find it helpful to start by writing a tiny program and
> actually try seeing what Perl tells you about syntax errors!
>
> There are CPAN modules that simplify reading filenames from a directory.



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

Date: Fri, 10 Nov 2006 09:21:17 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Generate HTML from a Windows Network Share
Message-Id: <ej1ct9$fe3$2@nntp.fujitsu-siemens.com>

rob wrote:
> That was incredibly helpful. :)
>=20
> I do have one more question thought..
>=20
> I've now got the program reading a specified directory, gathering the
> data from the directory and then outputting it to an html file just
> fine ... however, I'd like to include the subdirectories that are
> located in that directory .... is there a way to do this? Or will I
> simply have to write a new section of code for each subdirectory that I=

> want to include in this report?

Look at the File::Find module.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Fri, 10 Nov 2006 10:39:23 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Generate HTML from a Windows Network Share
Message-Id: <j0i8l25ba2rfmvnka2eaaudusnshefqenk@4ax.com>

On Wed, 08 Nov 2006 17:33:46 +0000, Ian Wilson
<scobloke2@infotop.co.uk> wrote:

>> opendir($path) \ die "Can't open $path";
>
>1. Use the vertical bar for a high precendence "or".

That would be *bitwise* "or". ITYM C<||>.

>2. For this circumstance, I prefer the word "or" instead.
>    (there are precedence pitfalls for the unwary)

And the general rule of thumb is: use high precedence one(s)[*] to
operate on values, and low precedence one(s) for flow control.


[*] The same applies to C<&&> and C<and> respectively. (And to C<//>
and C<err>.)


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 10 Nov 2006 09:50:36 +0000
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Generate HTML from a Windows Network Share
Message-Id: <pIKdndeZJqXz1snYnZ2dnUVZ8tednZ2d@bt.com>

rob wrote:
> 
> I've now got the program reading a specified directory, gathering the
> data from the directory and then outputting it to an html file just
> fine ... however, I'd like to include the subdirectories that are
> located in that directory .... is there a way to do this? Or will I
> simply have to write a new section of code for each subdirectory that I
> want to include in this report?

Josef has given the 'best practise' answer to this. The old fashioned 
answer is to use recursion. You could modify your program, put the 
directory scanning code in a subroutine, pass the starting directory as 
a parameter. Then, when iterating over the list of files you use the 
'-d' test to see if the file is in fact a directory, if so call the 
subroutine from witin itself to process the subdirectory.

Your code is a bit old fashioned so I've added some suggestions:

> 
> Here's an example of my code ::
> 
> my($my_path) = ('c:\\other\\');

You don't need brackets around a list of one element
   my $my_path = 'c:\\other\\';

> 
> opendir (DIR, $my_path) or die "Can't open $my_path";

Current best practise is to
- use lexical filehandles:
    opendir my $dirhandle, $my_path
- include error cause ($!) in message:
    or die "can't open $my_path because $!";

> 
> my(@files) = grep {/.+\.\w{3}$/i} readdir(DIR);
> 
> closedir(DIR);
> 
> open (MYFILE, '>data.html');

   or die "Can't open data.html because $!";

> foreach my $filename (files){print MYFILE "$filename\n";}

Are you re-typing rather than cutting and pasting? That should be 
(@files) not (files).

It doesn't look much like HTML either :-)

> 
> close (MYFILE);
> 


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

Date: 9 Nov 2006 22:28:54 -0800
From: "badarisj@gmail.com" <badarisj@gmail.com>
Subject: guaranteeing interrupt handling
Message-Id: <1163140134.519910.167480@h54g2000cwb.googlegroups.com>

folks,

the interrupts like INT and QUIT are ignored during the calls to
'system'
builtin. If you have some cleanup code that you DO want executed
how can we guarantee the execution?
especially this problem would be aggravated if your perl-module
depends on bunch of other perl-modules -- you would NOT know
if and when the perl-modules you call are invoking 'system' builtin.

does placing code in DESTROY guarantee the execute with interrupts
like (INT and QUIT)?

thanks,
-badari



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

Date: Fri, 10 Nov 2006 06:09:39 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: how to source an environment file
Message-Id: <J8I3s2.o1@news.boeing.com>

dcruncher4@aim.com wrote:
> I want my perl script to read a file containing environment variables
> and source it back
> to the script. That is, when the script is executed, these variables
> are not defined
> in enviroment. Once the script starts, variables defined in that env
> file is sourced
> in. In korn shell we can do
>                 dot(.) scriptname
> 
> How do we do the same in perl.
> 
> I found a crude approach. I do
> system(". scriptname; env > /tmp/env.$$")
> then I open /tmp/env.$$ file and store all env defined there
> in $ENV{envvar}.
> 

scriptname:
export DUM1=foo
 ..

perl -le 'BEGIN{ system(". /path/to/scriptname")== 0 or die "source 
failed: $?};  use Env; print $ENV{DUM1};'


--
Charles DeRykus


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

Date: 10 Nov 2006 08:21:39 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: how to source an environment file
Message-Id: <4rir4jFrgrvdU1@mid.dfncis.de>

Charles DeRykus  <ced@blv-sam-01.ca.boeing.com> wrote in comp.lang.perl.misc:
> dcruncher4@aim.com wrote:
> > I want my perl script to read a file containing environment variables
> > and source it back
> > to the script. That is, when the script is executed, these variables
> > are not defined
> > in enviroment. Once the script starts, variables defined in that env
> > file is sourced
> > in. In korn shell we can do
> >                 dot(.) scriptname
> > 
> > How do we do the same in perl.
> > 
> > I found a crude approach. I do
> > system(". scriptname; env > /tmp/env.$$")
> > then I open /tmp/env.$$ file and store all env defined there
> > in $ENV{envvar}.
> > 
> 
> scriptname:
> export DUM1=foo
> ..
> 
> perl -le 'BEGIN{ system(". /path/to/scriptname")== 0 or die "source 
> failed: $?};  use Env; print $ENV{DUM1};'

Did you test that?

Environment variables from .../scriptname will not become available.  What
is "use Env" supposed to do?

Anno


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

Date: 9 Nov 2006 22:48:34 -0800
From: "Maneesh" <mmanocha@gmail.com>
Subject: LAN Crawler
Message-Id: <1163141314.898228.74040@k70g2000cwa.googlegroups.com>

Hi,

I am looking some pointer to a perl script which can crawl through the
shared direcotries on the LAN and get me the list of files are which
are shared.

Any references / pointers shall be greatly appreciated !

-Maneesh



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

Date: 9 Nov 2006 18:33:48 -0800
From: huntingseasonson@gmail.com
Subject: Net::FTP Wierdness; or Not.....
Message-Id: <1163126028.886189.276590@i42g2000cwa.googlegroups.com>

Doing batches of FTP transfers. Most of the time they work, sometimes
they dont. When they dont, the error messages seem to be the response
from the FTP server acknowledging my previous command, or empty.

Heres the code:
sub ftp_transfer()
{
my $ftp = Net::FTP->new($host) ||  _error("Can't connect to host $host:
$@");


      _netcmd_error($ftp,"Can't login to $host as $username: "
$ftp->message)
          unless $ftp->login($username,$password);


      if( $ftp->ls($package) ) {

          _log("Remote directory $package already exists");

          unless($config{overwrite}) { #no need to continue unless
caller wants to overwrite
             $ftp->quit;
             return;
          }

           _log("Overwriting remote directory $package");
      }
      else {
        _netcmd_error($ftp,"Can't create remote directory $package: " .
$ftp->message)
            unless $ftp->mkdir($package);
      }

      _netcmd_error($ftp,"Can't change to remote directory $package: "
 . $ftp->message)
          unless $ftp->cwd($package);
     _netcmd_error($ftp,"Can't transfer file $file: " . $ftp->message)
unless $ftp->put($file);

     _netcmd_error($ftp,"Can't switch to binary mode: " .
$ftp->message) unless $ftp->binary;

###############################################################################
#ERROR COMES FROM HERE
     _netcmd_error($ftp,"Can't transfer file $video: " . $ftp->message)
unless $ftp->put($video);
################################################################################

      $ftp->quit;

      return 1;
}

_error() logs the error and sends an email alert, _netcmd_error calls
quit() on the ftp object and then calls _error()

The error I get is either: "Opening BINARY mode data connection for
xyz.mpg"
or empty.

Humm, I guess its probably better to call binary() 1st. But I cant
understand why the 2nd put() call fails with either nothing in
message(), or the response from the server when I called binary(). The
perldocs say that all calls return a true or false to indicate success
or failure,  unless otherwise noted. So it is failing, but the message
is faulty. I really dont know.

Thanks



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

Date: Fri, 10 Nov 2006 03:10:37 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Net::FTP Wierdness; or Not.....
Message-Id: <d67d24-qth.ln1@osiris.mauzo.dyndns.org>


Quoth huntingseasonson@gmail.com:
> Doing batches of FTP transfers.

It is considered polite here to write in complete sentences.

> Most of the time they work, sometimes
> they dont. When they dont, the error messages seem to be the response
> from the FTP server acknowledging my previous command, or empty.
> 
> Heres the code:
> sub ftp_transfer()
                  ^^
Do you know what this does? If not, don't put it there.

> {
> my $ftp = Net::FTP->new($host) ||  _error("Can't connect to host $host:
> $@");

What is $host? I hope you're not passing values into subroutines through
globals: that's considered very bad style, for a number of good reasons.

>       _netcmd_error($ftp,"Can't login to $host as $username: "
> $ftp->message)

This line is not valid Perl. Are you missing a .?

>           unless $ftp->login($username,$password);

This would be much clearer written as

    $ftp->login($username, $password)
        or _netcmd_error $ftp, 
            "Can't login to $host as $username: " . $ftp->message;

The point of the and and or operators is that they let you put the
important bit--what you're doing--first, and the error-handling
afterwards.
            
>       if( $ftp->ls($package) ) {
> 
>           _log("Remote directory $package already exists");
> 
>           unless($config{overwrite}) { #no need to continue unless
> caller wants to overwrite
>              $ftp->quit;
>              return;
>           }
> 
>            _log("Overwriting remote directory $package");
>       }
>       else {

unless (...) { } else { } is very confusing. If you need both branches,
just use an ordinary if.

>         _netcmd_error($ftp,"Can't create remote directory $package: " .
> $ftp->message)
>             unless $ftp->mkdir($package);
>       }
> 
>       _netcmd_error($ftp,"Can't change to remote directory $package: "
> . $ftp->message)
>           unless $ftp->cwd($package);
>      _netcmd_error($ftp,"Can't transfer file $file: " . $ftp->message)
> unless $ftp->put($file);
> 
>      _netcmd_error($ftp,"Can't switch to binary mode: " .
> $ftp->message) unless $ftp->binary;
> 
> #################################################
> #ERROR COMES FROM HERE
>      _netcmd_error($ftp,"Can't transfer file $video: " . $ftp->message)
> unless $ftp->put($video);
> #################################################
> 
>       $ftp->quit;
> 
>       return 1;
> }
> 
> _error() logs the error and sends an email alert, _netcmd_error calls
> quit() on the ftp object and then calls _error()
> 
> The error I get is either: "Opening BINARY mode data connection for
> xyz.mpg"
> or empty.
> 
> Humm, I guess its probably better to call binary() 1st. But I cant
> understand why the 2nd put() call fails with either nothing in
> message(), or the response from the server when I called binary(). The
> perldocs say that all calls return a true or false to indicate success
> or failure,  unless otherwise noted. So it is failing, but the message
> is faulty. I really dont know.

From a quick look at the source of Net::FTP, I would say that if the put
fails sometime during the transfer (that is, if the STOR FTP command
succeeds but the actual transfer fails) then $ftp->message will not
contain anything useful. Try your transfer passing the Debug => 1 option
to Net::FTP to see if you can work out what's going wrong.

Ben

-- 
I touch the fire and it freezes me,               [benmorrow@tiscali.co.uk]
I look into it and it's black.
Why can't I feel? My skin should crack and peel---
I want the fire back...                     Buffy, 'Once More With Feeling'


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

Date: Fri, 10 Nov 2006 05:42:10 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Nov 10 2006
Message-Id: <J8I2IA.1vIF@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.

Alzabo-0.8902
http://search.cpan.org/~drolsky/Alzabo-0.8902/
A data modelling tool and RDBMS-OO mapper
----
BatchSystem-SBS-0.08
http://search.cpan.org/~alexmass/BatchSystem-SBS-0.08/
a Simple Batch System
----
CORBA-Python-0.30
http://search.cpan.org/~perrad/CORBA-Python-0.30/
----
Cairo-1.02
http://search.cpan.org/~tsch/Cairo-1.02/
Perl interface to the cairo library
----
DBD-DB2-1.0
http://search.cpan.org/~ibmtordb2/DBD-DB2-1.0/
List of changes
----
Env-Path-0.18
http://search.cpan.org/~dsb/Env-Path-0.18/
Advanced operations on path variables
----
Finance-MICR-LineParser-1.05
http://search.cpan.org/~leocharre/Finance-MICR-LineParser-1.05/
validate and parse a MICR code from a string
----
HTTP-Daemon-App-v0.0.1
http://search.cpan.org/~dmuey/HTTP-Daemon-App-v0.0.1/
Create 2 or 3 line, fully functional (SSL) HTTP server(s)
----
IPC-PerlSSH-0.03
http://search.cpan.org/~pevans/IPC-PerlSSH-0.03/
a class for executing remote perl code over an SSH link
----
Lingua-Identify-0.19
http://search.cpan.org/~cog/Lingua-Identify-0.19/
Language identification
----
Locale-Maketext-Utils-v0.0.6
http://search.cpan.org/~dmuey/Locale-Maketext-Utils-v0.0.6/
Adds some utility functionality and failure handling to Local::Maketext handles
----
Mobile-Wurfl-1.05
http://search.cpan.org/~awrigley/Mobile-Wurfl-1.05/
a perl module interface to WURFL (the Wireless Universal Resource File - <http://wurfl.sourceforge.net/>).
----
POE-Component-Daemon-0.1002
http://search.cpan.org/~gwyn/POE-Component-Daemon-0.1002/
Handles all the housework for a daemon.
----
SVN-Notify-Config-0.0906
http://search.cpan.org/~jpeacock/SVN-Notify-Config-0.0906/
Config-driven Subversion notification
----
Sys-MemInfo-0.91
http://search.cpan.org/~scresto/Sys-MemInfo-0.91/
----
Test-ISBN-1.08
http://search.cpan.org/~bdfoy/Test-ISBN-1.08/
Check International Standard Book Numbers
----
Text-Diff-Parser-0.03
http://search.cpan.org/~gwyn/Text-Diff-Parser-0.03/
----
Text-Diff-Parser-0.04
http://search.cpan.org/~gwyn/Text-Diff-Parser-0.04/
Parse patch files containing unified and standard diffs
----
Unix-PID-v0.0.7
http://search.cpan.org/~dmuey/Unix-PID-v0.0.7/
Perl extension for getting PID info.
----
Unix-PID-v0.0.8
http://search.cpan.org/~dmuey/Unix-PID-v0.0.8/
Perl extension for getting PID info.
----
bioperl-1.5.2-RC3
http://search.cpan.org/~sendu/bioperl-1.5.2-RC3/


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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 10 Nov 2006 07:35:17 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: PERL can't open file for logging (world writable directory Windows XP Home/ Active Perl / Apache)
Message-Id: <VYV4h.4715$l25.3264@newsread4.news.pas.earthlink.net>

On 11/09/2006 11:11 AM, PGPS wrote:
> Sisyphus wrote:
>> "PGPS" <premgrps@gmail.com> wrote in message
>> news:1163026204.175252.217270@e3g2000cwe.googlegroups.com...
>> .
>> .
>>> 4. With this setup, I get an error "Cannot open file" in the error logs
>>> of Apache.
>> Can you extend that error message to include the name of the file that perl
>> couldn't open (in case it's not the file you think it was), and to include
>> the contents of $!.
>>
>> Cheers,
>> Rob
> 
>
> [...] I put the same question in Apache groups and I got a response
> saying that "That's how it should be".
>
> My question is: "What's the solution to get it working". Since, on the
> Linux machine, on which I just had a user login (on someone else's
> server), I could get it working. So, the configuration was changed. The
> problem is not just HTML, I would like all the depended filies like
> *.js, *.jpg, *.css, *.gif to be in the same directory as the program.
>
> Anyway, the above is a Apache configuration problem. Below is my PERL
> problem.
>
> Below is the code:
>
> open(LOGFILE, ">>/logs.html");
> print LOGFILE "Some stuff here\n";
> close(LOGFILE);
>
> The error in the apache access logs is something to the effect that
> "Cannot open file" and it points to the line number in the PERL program
> which has this line:
>
> open(LOGFILE, ">>/logs.html");

Why are you trying to write in the root directory? Does your web-server
has permission to write there?

>
> DIRECTORY STRUCTURE
> [htdocs]
>          logs.html
> [cgi-bin]
>           [program1]
>                        prog1.cgi
>
> htdocs and cgi-bin directories are in the same parent directory.
> htdocs has logs.html file
> cgi-bin has a folder called program1 and program1 folder has prog1.cgi
>
>
>
> Thanks.
>

1) The /.../htdocs directory almost certainly has different permissions
than the / (root) directory.

2) Often, web-servers don't have permission to write into their own
 .html files because an intruder who manages to break into the web-server
can easily deface the website. You might have to change the permissions
on /.../htdocs/ and deal with the consequences.


-- 
paduille.4060.mumia.w@earthlink.net



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

Date: Fri, 10 Nov 2006 02:48:16 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: PERL can't open file for logging (world writable directory Windows XP Home/ Active Perl / Apache)
Message-Id: <jeadnRSzdIOuxMnYnZ2dnUVZ_u6dnZ2d@comcast.com>

PGPS wrote:

> open(LOGFILE, ">>/logs.html");
> 
> DIRECTORY STRUCTURE
> [htdocs]
>          logs.html
> [cgi-bin]
>           [program1]
>                        prog1.cgi

That open() statement is definitely wrong.

   my $file = "$ENV{DOCUMENT_ROOT}/logs.html"; # Use full path name
   open(LOGFILE, ">>$file") or die "Cannot append to $file: $!\n";

To access anything in htdocs, you need to either use a hardcoded
absolute pathname (such as "/var/www/htdocs/logs.html") or use
an ENV variable (such as what I've shown above).

Remember, when the web server receives a request for "/logs.html"
(such as from <a href="/logs.html">Log files</a>), it converts that
string to a file name by using ServerRoot and/or DocumentRoot.
Your CGI program needs to do the same thing; it cannot simply
use the string "/logs.html" as it and expect it to work.

	-Joe


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

Date: Fri, 10 Nov 2006 02:45:12 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: perl command line arguements
Message-Id: <om5d24-4tb.ln1@osiris.mauzo.dyndns.org>


Quoth "mrinalini.sukumar@gmail.com" <mrinalini.sukumar@gmail.com>:
> 
> I have associate the perl executable to the .pl extension.  The file
> association works fine when I don't use the command line arguements,
> but fails when I pass the command line arguements. When I execute the
> same command by appending the perl command in the beginning, it works
> fine. Does anyone know how to get around the problem? I am using perl
> 5.8.8 and I downloaded it from the activestate website.

You have the association wrong. On my windows machine, I get:

C:\DOCUME~1\Ben\Desktop>type foo.plx
#!perl -l

use Win32::TieRegistry Delimiter => '/';

print for @ARGV;

my $type = $Registry->{'Classes/.plx//'};
my $verb = $Registry->{"Classes/$type/shell//"};
print $Registry->{"Classes/$type/shell/$verb/command//"};

C:\DOCUME~1\Ben\Desktop>foo.plx a b c
a
b
c
"C:\Perl\bin\perl.exe" "%1" %*

C:\DOCUME~1\Ben\Desktop>

In particular, note the %* in the last line of output. ISTR I had to put
that in myself: the windows 'Open with...' dialog didn't. (I use .plx
rather than .pl for Perl programs to be executed, rather than
Perl4-style library files.) Another useful setting is

$Registry->{"Classes/$type/shellex/DropHandler//"} =
    $Registry->{'Classes/exefile/shellex/DropHandler//'};

(with $type as above) which will (once the above association is correct)
allow you to drag-and-drop files onto a .plx file to invoke it with
those filenames.  Unfortunately they are always short (8.3) names, but
that can be fixed with Win32::GetLongPathName if necessary.

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality. [Samuel Butler, paraphrased] benmorrow@tiscali.co.uk


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

Date: 10 Nov 2006 00:17:40 -0800
From: "enigma" <mabounajm@gmail.com>
Subject: Re: Perl runtime error after installing oracle 10g
Message-Id: <1163146659.978101.262560@e3g2000cwe.googlegroups.com>

Hi,

Thanks alot..I did something similar...unsetting an environment
variable by:
 @set PERL5LIB=

Perl's work wonderfully as before..Still don't know how would oracle
behave!

Mazen

Ingo Menger wrote:
> enigma schrieb:
>
> > Hi,
> >
> > I have a perl script which i've been using perfectly with no trouble at
> > all.. Two days ago i installed Oracle 10g. After i tried to run my
> > script.. A pop window tells me:
> >
> > The application has failed to start because Perl56.dll was not found.
> > Re-installing the application may fix this problem.
> >
> > After I press OK, i get these errors
> >
> > Can't load
> > 'C:\oracle\product\10.1.0\Db_1\perl\5.6.1\lib\MSWin32-x86/auto/IO/IO.dll'
> > for module IO: load_file:The specified module could not be found at
>
> This is typical. Just when you think you have your working environment
> complete, ohh almost, I just install XYZ 5.47, then it happens.
> The stupid, dumb bastards of the XYZ company include java 1.2.7 or perl
> 5.6.1 in their distribution and they make sure, this is called when you
> say java or perl.
> (A notable exception is NoMagic, they ask during install of MagicDraw
> if they should use the java engine that's already installed.)
>
> I recommend the following: find the perl.exe and all perl*dll that is
> in the oracle file tree and rename them.
> Or remove the correponding entry from PATH, if you can.
> After that, your normal perl should work as before.
>
> Take care: some Oracle patch procedures may rely on *their* shipped
> perl version. Therefore, before doing another oracle upgrade or patch,
> recreate the state of the system you have now (i.e. "perl" would call
> the perl shipped with Oracle)
>
> To take the different perls apart, perl -v or perl -V should help. It
> shows, among others, the default @INC-path.



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

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


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